Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[43] Only call getPackageForURI on URI-like paths #45

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pcdavid
Copy link
Member

@pcdavid pcdavid commented Jun 24, 2024

This avoids creating thousands of PackageNotFoundError instances when
resolving "normal" inter-document references which do not refer to
EPackages via nsURIs.

PackageNotFoundError are much cheaper to create than the previously
used PackageNotFoundException, but that's still a lot of garbage
instances to create, add into the resource.getErrors() list and never
use (or even clear).

In addition, in the context of Sirius Web, every instance will have
its own duplicate string representation of the failed "package" URI
because we get it from EObjectIDManager.getOrCreateId(EObject) which
invokes UUID.toString() and allocates a new (identical) String each
time.

Bug: #43
Signed-off-by: Pierre-Charles David [email protected]

This avoids creating thousands of PackageNotFoundError instances when
resolving "normal" inter-document references which do not refer to
EPackages via nsURIs.

PackageNotFoundError are much cheaper to create than the previously
used PackageNotFoundException, but that's still a lot of garbage
instances to create, add into the resource.getErrors() list and never
use (or even clear).

In addition, in the context of Sirius Web, every instance will have
its own duplicate string representation of the failed "package" URI
because we get it from EObjectIDManager.getOrCreateId(EObject) which
invokes UUID.toString() and allocates a new (identical) String each
time.

Bug: #43
Signed-off-by: Pierre-Charles David <[email protected]>
@pcdavid pcdavid linked an issue Jun 24, 2024 that may be closed by this pull request
@pcdavid pcdavid added this to the 2024.7.0 milestone Jun 24, 2024
Comment on lines +547 to 554
if (resourceURIPath.indexOf(SCHEME_SEPARATOR) != -1) {
EPackage ePackage = this.getPackageForURI(resourceURIPath);
if (ePackage != null) {
object = ePackage.eResource().getEObject(fragmentEMF);
}
} else {
object = this.createProxyEObject(id, qualifiedType, eReference);
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the new logic is wrong. It assumes only resources from the package registry have full URI paths (with scheme, separator, etc.). This will not be the case in e.g. SysON where standard libraries, which are plain models, have URIs of the form kermllibrary://<uuid>. With the new code, such a URI would be lookup up in the package registry (because is has a :), which will fail, and we'll stop there. We should fall back to the this.createProxyEObject() in this case as in a non-URI-like path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PackageNotFoundErrors use significant amount of memory
1 participant