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

Maximize usage of ImmutableCapabilities to further reduce memory usage and simplify code #23695

Merged
merged 5 commits into from
Jan 30, 2023

Conversation

tresat
Copy link
Member

@tresat tresat commented Jan 27, 2023

Makes ImmutableCapabilities class thoroughly immutable by verifying immutability of all contents as they are added. This add references to already immutable capabilities, and duplicates non-immutable capabilities as immutable types.

Renames DefaultShadowedCapability to ImmutableShadowedCapability to advertise immutability. Also check that the shadowed capability is immutable upon construction, or make an immutable copy.

The result of this is to make the DefaultArtifactSelector more efficient in two ways. It can defer creation of a fallback capabilities collection until it is actually needed. It can also reuse existing immutable capabilities rather than creating new instances, as the immutable types will never change.

This saves 16MB or so during the large sync scenario testing by creating less ImmutableCapabilities and ImmutableCapability objects which are equivalent.

The top image shows the new results, the bottom shows the old:

image

@gradle gradle deleted a comment from tresat Jan 28, 2023
@gradle gradle deleted a comment from tresat Jan 28, 2023
@tresat tresat force-pushed the tt/memory/immutable-capabilities branch from d7c7693 to 144af84 Compare January 28, 2023 15:29
@gradle gradle deleted a comment from tresat Jan 28, 2023
@tresat tresat self-assigned this Jan 28, 2023
@tresat tresat changed the title WIP: Immutability Experiment Maximize usage of ImmutableCapabilities to further reduce memory usage and simplify code Jan 28, 2023
@tresat tresat added this to the 8.1 RC1 milestone Jan 28, 2023
@tresat tresat marked this pull request as ready for review January 28, 2023 18:02
@tresat tresat requested a review from a team as a code owner January 28, 2023 18:02
@tresat tresat requested review from ghale, big-guy and jvandort and removed request for ghale January 28, 2023 18:02
@gradle gradle deleted a comment from tresat Jan 28, 2023
@tresat
Copy link
Member Author

tresat commented Jan 28, 2023

@bot-gradle test this

@gradle gradle deleted a comment from tresat Jan 28, 2023
@bot-gradle
Copy link
Collaborator

I've triggered the following builds for you:

@tresat
Copy link
Member Author

tresat commented Jan 30, 2023

@bot-gradle test and merge

@gradle gradle deleted a comment from tresat Jan 30, 2023
@bot-gradle
Copy link
Collaborator

I've triggered a build for you.

@bot-gradle bot-gradle merged commit 17affc8 into master Jan 30, 2023
@bot-gradle bot-gradle deleted the tt/memory/immutable-capabilities branch January 30, 2023 18:26
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.

3 participants