Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Shared utility object for entire project build
Shared utility object for entire project build [message #1844618] Fri, 17 September 2021 18:21 Go to next message
Elie Richa is currently offline Elie RichaFriend
Messages: 72
Registered: February 2016
Member
Hello folks,

In the generator of my language, I need to resolve a set of objects given a set of known static qualified names. Essentially the generator is aware of a set of qualified names of objects known exist in the project being built. It's a sort of a standard library, but since it's still evolving, for the moment it exists in the runtime project.

In the generator, I use the index the resolve the qualified names into objects as follows:

    @Inject extension IndexUtils

    def locateObj(EObject context, QualifiedName name) {
        context.visibleContainers.flatMap[exportedObjects].findFirst [
            name == it.name
        ]?.EObjectOrProxy
    }


This is proving quite costly in terms of performance because we query the index again each time the generator is called for each resource.

Is there a way to perform this resolution once at the beginning of a project build, and use the same resolved objects for all resources processed in the scope of that build?

Perhaps by initializing a utility object that contains the references to the resolved objects and is shared by all generators called during the build?

Thanks.


Elie Richa, Ph.D
Software Engineer, AdaCore
https://www.adacore.com
Re: Shared utility object for entire project build [message #1844619 is a reply to message #1844618] Fri, 17 September 2021 18:30 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
what about caching the thing as an eadapter to the resourceset?

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Shared utility object for entire project build [message #1844620 is a reply to message #1844619] Fri, 17 September 2021 18:35 Go to previous messageGo to next message
Elie Richa is currently offline Elie RichaFriend
Messages: 72
Registered: February 2016
Member
That sounds like a great idea since the resource set is the same throughout the build. I will try it on Monday.

Thanks!


Elie Richa, Ph.D
Software Engineer, AdaCore
https://www.adacore.com
Re: Shared utility object for entire project build [message #1844623 is a reply to message #1844620] Fri, 17 September 2021 19:20 Go to previous messageGo to next message
Neeraj Bhusare is currently offline Neeraj BhusareFriend
Messages: 177
Registered: July 2009
Location: Canada
Senior Member
The code generators are typically performance-intensive, especially if you have projects containing thousands of DSLs.

Have you profiled your application? From what I understand a proxy is resolved only once. Thereafter the resolved EObject is returned for every consecutive call.

You also need to check what goes into the Index. You can control what goes into the index by defining a custom ResourceDescriptionStrategy, and thus reducing the iterations you do in your generator.

@ Christian Please correct me if I am wrong above. Tx.





Twitter : @NeerajBhusare
Blog : https://nbhusare.github.io/
Best regards, Neeraj
Re: Shared utility object for entire project build [message #1844640 is a reply to message #1844623] Sun, 19 September 2021 18:37 Go to previous message
Elie Richa is currently offline Elie RichaFriend
Messages: 72
Registered: February 2016
Member
Hello Neeraj,

Thank you for your reply.

Indeed I have profiled my application and observed the most significant bottleneck at the moment seems to be the querying of the index, and I think there are two reasons for that.

The first reason is that even though resolution happens once, it happens once per resource because a fresh generator is instantiated for each resource (I think?). Since I have hundreds of resources and tens of qualified names to resolve, I end up with thousands of unnecessary resolutions.

The second reason is that the index is organized by resource URI whereas my qualified names are not. So to perform my lookup I am having to combine all global object descriptions into the same iterator to query it. I think that performance could be better if I first query the index for the resource description of the resource where I know the qualified names are, and then query only that description.

But generally I felt it better to address the first point first, i.e. try to only perform the resolution once for all resources instead of once per resource.

Regards,


Elie Richa, Ph.D
Software Engineer, AdaCore
https://www.adacore.com
Previous Topic:Implicit Model Elements
Next Topic:How to stop the validation programmatically for dsl project
Goto Forum:
  


Current Time: Wed Apr 24 14:38:19 GMT 2024

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

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

Back to the top