Shared utility object for entire project build [message #1844618] |
Fri, 17 September 2021 14:21  |
Eclipse User |
|
|
|
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.
|
|
|
|
|
|
Re: Shared utility object for entire project build [message #1844640 is a reply to message #1844623] |
Sun, 19 September 2021 14:37  |
Eclipse User |
|
|
|
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,
|
|
|
Powered by
FUDForum. Page generated in 0.05344 seconds