Clone
Lari Hotari <lari.hotari@gradle.com>
committed
on 03 Oct 16
De-duplicate (= intern) some instances in dependency resolution
- Reduce memory usage of dependency resolution by de-duplicating the
most … Show more
De-duplicate (= intern) some instances in dependency resolution

- Reduce memory usage of dependency resolution by de-duplicating the

 most commonly used immutable instances.

- Objects aren't strictly immutable: displayName is calculated lazily

 - solution is thread-safe without synchronization

 - lazy calculation is needed for efficient interning since a lookup

   will always create a new instance.

- Use strong references in some instance interners

 - strong references cause less GC overhead than weak references

- Strong references:

   DefaultModuleIdentifier

   DefaultModuleVersionIdentifier

   DefaultModuleVersionSelector

   DefaultModuleComponentIdentifier

   DefaultModuleComponentSelector

   DefaultProjectComponentSelector

- Weak references:

   DefaultLibraryBinaryIdentifier

   DefaultLibraryComponentSelector

   DefaultIvyArtifactName

- Both reference types:

   DefaultBuildIdentifier

   DefaultProjectComponentIdentifier

       - The reason for special handing is that DefaultBuildIdentifier

         has a state field "current" as part of the instance which

         isn't part of equals/hashCode.

+review REVIEW-6277

Show less

green-master + 408 more