Community
Participate
Working Groups
The StateHelperImpl class in org.eclipse.osgi.internal.resolver has three instances where collections are created with initial capacity 11: Map result = new HashMap(11); HashSet result = new HashSet(11); in methods getExportedPackageMap(), getGenericsMap(), and getUnsatisfiedLeaves(). When the state contains a large number of bundles (I am running scenarios with ~4000 bundles) performance suffers very significantly due to rehashing. For example, in getGenericsMap() where the result grows to over 6000 elements, the call takes over 30 minutes. The initial capacity of the these collections should be computed based on the number of bundles in the state.
Added performance keyword.
Do have to watch the converse. For example, in "normal" circumstances there tend to be very few unsatisfied leaves.
I think the real cost is the call to isResolvable(GenericSpecification) from getUnsatisfiedConstraints(BundleDescription) which is called for each bundle passed to getUnsatisfiedLeaves(State, BundleDescription[]) The method isResolvable(GenericSpecification) will reconstruct the Map of generics each call. This will quickly get out of hand if you have lots of BundleDescriptions with generic constraints. Pascal, is the provisioning work is using generic constraints extensively? I think you are mapping the constraints to generics, right? If so I can see how this has just now surfaced as an issue.
I noticed the class org.eclipse.equinox.prov.resolution.ResolutionHelper is calling StateHelper.getUnsatisfiedLeaves for every BundleDescription that got installed individually. Why is this done for each individual BundleDesciption, also should it not only do this if the BundleDescription is unresolved? Is there any way you can pass all the added bundles in a single call to StateHelper.getUnsatisfiedLeaves? To improve performance in this area we should move the hashing to StateImpl so that we do not have to keep reconstructing the Maps with each call to the static StateHelper methods.
No plans to address this.