Skip to content

Weak cache optimization - #5344

Merged
trask merged 1 commit into
open-telemetry:mainfrom
trask:weak-cache-optimization
Feb 11, 2022
Merged

Weak cache optimization#5344
trask merged 1 commit into
open-telemetry:mainfrom
trask:weak-cache-optimization

Conversation

@trask

@trask trask commented Feb 11, 2022

Copy link
Copy Markdown
Member

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
Copy Markdown
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
Copy Markdown
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 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
Copy Markdown

@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

trask commented Jun 28, 2022

Copy link
Copy Markdown
Member Author

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

@danielqsj

Copy link
Copy Markdown

@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.

5 participants