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

Reduce Resolver Related Class-Instances #16

Open
BenjaminKlatt opened this issue Jan 2, 2014 · 0 comments
Open

Reduce Resolver Related Class-Instances #16

BenjaminKlatt opened this issue Jan 2, 2014 · 0 comments

Comments

@BenjaminKlatt
Copy link
Contributor

Issue Description

The resolver logic is structured into several classes for better seperation of concerns. However, there are more instances of those classes created as necessary.

Code Review Results

JavaDefaultResolverDelegate

  • is used by the IJavaReferenceResolver implementations (e.g. AnnotationAttributeSettingAttributeReferenceResolver)
    They use the deResolve() method only which is thread safe, stateless and process submitted call arguments only.
    => It is an option to let all of them use only a single static instance

IJavaReferenceResolver

The different IJavaReferenceResolver implementations are instantiated by the JavaReferenceResolverSwitch only.
They are all stateless, and all of their setOptions() methods do nothing.
=> All JavaReferenceResolverSwitch instances could use the same resolver instances.

JavaReferenceResolverSwitch

As mentioned before, the resolver in the switch are stateless. The switch's setOptions()-method delegates the options map to the setOptions()-method of the resolvers, which again do nothing.
=> A single instance of the switch would be fine for the whole JaMoPP instance.
=> Within JaMoPP, there are 6 locations creating JavaReferenceResolverSwitch instances. (See screenshot below).
jamopp-javareferenceresolverswitch-instantiations

Recommended Adaptation

The locations within the src-gen source directory make all use of the JavaMetaInformation class, which already located in the manually modified source directory. Only JavaResource does create a new switch on it's own. Instead of the JavaResource itself, the JavaSourceOrClassFileResource is used, which is located in java.resource manually adapted source directory.
This allows to modify all 6 locations at already not-generated code locations.

To reduce the instantiation overhead and the memory footprint, these 6 locations should be adapted to request the switch from a factory using the same thread safe singleton.

Optimization Results

With the ArgoUML case study from the SPLevo/KoPL project, for example, the number of delegate instances has been reduced from > 450k (continuously increasing while the case study could not be finished) to 7 constant instances.
Also the switches and Resolvers have been reduced to constant number.

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

No branches or pull requests

1 participant