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

Weak cache optimization #5344

Merged
merged 1 commit into from Feb 11, 2022
Merged

Conversation

trask
Copy link
Member

@trask trask commented Feb 11, 2022

No description provided.

if (value != null) {
return value;
}
// Best we can do, we don't expect high contention with this implementation. Note, this
Copy link
Contributor

Choose a reason for hiding this comment

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

Oof yeah stopped being true when stopped using caffeine

resetLookupKey(lookupKey);
}
return previous == null
? target.computeIfAbsent(new WeakKey<>(key, this), ignored -> mappingFunction.apply(key))
Copy link
Contributor

Choose a reason for hiding this comment

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

I thought this was impossible due to needing to pass the weak key to mapping function but the solution of using a capturing lambda was so simple!

@trask trask marked this pull request as ready for review February 11, 2022 01:53
@trask trask requested a review from a team as a code owner February 11, 2022 01:53
@trask trask merged commit 54e6b12 into open-telemetry:main Feb 11, 2022
@trask trask deleted the weak-cache-optimization branch February 11, 2022 17:31
RashmiRam pushed a commit to RashmiRam/opentelemetry-auto-instr-java that referenced this pull request May 23, 2022
@danielqsj
Copy link

@trask as this PR #5316 described, WeakLockFreeCache.computeIfAbsent() relay on the expungeStaleEntries() to clean up weak keys.
After this PR, It seems WeakLockFreeCache.computeIfAbsent() cannot clean up anymore.

@trask
Copy link
Member Author

trask commented Jun 28, 2022

thx @danielqsj! can you open an issue for this?

@danielqsj
Copy link

@trask sure. This issue #6230.

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.

None yet

5 participants