Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Performance implication of using xtextResource.getContents().get(0)
Performance implication of using xtextResource.getContents().get(0) [message #1817917] Tue, 03 December 2019 06:03 Go to next message
Neeraj Bhusare is currently offline Neeraj BhusareFriend
Messages: 177
Registered: July 2009
Location: Canada
Senior Member
Hi All,

While profiling a piece of code, I replaced the call to
xtextResource.getContents().get(0)
with
 xtextResource.getParseResult().getRootASTElement()

After making the change, I saw a drastic reduction in the time taken by the the method that contained in the above code.

The code `xtextResource.getContents().get(0)`, internally invokes the associated JVMModelInferrer which took most of the method execution time. My objective was to get hold of the root-object, at the same time avoid the call to the JVMModelInferrer, and the above change seems to fit the bill.

Is this a recommended thing to do? Can someone please confirm?


Twitter : @NeerajBhusare
Blog : https://nbhusare.github.io/
Best regards, Neeraj
Re: Performance implication of using xtextResource.getContents().get(0) [message #1817918 is a reply to message #1817917] Tue, 03 December 2019 06:56 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 762
Registered: July 2009
Location: Dortmund, Germany
Senior Member

The DerivedStateAwareResource will install the derived state, and in your case use the inferrer, when invoking getContents(). If you do not need to install the inferred JVM model, then this will be faster, sure. But why do you have an Xbase based language then?

I can't give a recommendation on that without knowing the real use case in detail. So as long as it works for you, why not? The general recommendation can only be to go the "normal" way, as it is safe in regards of the expected state of the resources.
Re: Performance implication of using xtextResource.getContents().get(0) [message #1817927 is a reply to message #1817918] Tue, 03 December 2019 09:12 Go to previous message
Neeraj Bhusare is currently offline Neeraj BhusareFriend
Messages: 177
Registered: July 2009
Location: Canada
Senior Member
Hi Karsten,

Thanks for your reply.

I have a cache that holds the top-level objects of different types in multiple maps, meant for faster access. The cache gets updated/refreshed from time to time, and the update strategy is required to be fast. I believe it doesn't make sense to install the derived state at this point.

I do have other places in the code (expression execution) where the derived state gets installed.


Twitter : @NeerajBhusare
Blog : https://nbhusare.github.io/
Best regards, Neeraj

[Updated on: Tue, 03 December 2019 09:19]

Report message to a moderator

Previous Topic:Question: DSL project with dependencies
Next Topic:Extending scope with dynamic references
Goto Forum:
  


Current Time: Tue Apr 16 18:11:32 GMT 2024

Powered by FUDForum. Page generated in 1.04527 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top