-
Notifications
You must be signed in to change notification settings - Fork 293
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
Replace Guava caches #2044
Replace Guava caches #2044
Conversation
} | ||
|
||
private static final long DEFAULT_CACHE_CAPACITY = 32; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no basis for this number. The alternative is removing newWeakCache()
and forcing callers to specify a capacity.
dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/tooling/CaffeineWeakCache.java
Show resolved
Hide resolved
|
||
String version = System.getProperty("java.version"); | ||
try { | ||
if (version == null || version.startsWith("1.7")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@devinsba mentioned encapsulating this in a Platform
class before, I think there are probably enough instances of this to do it now
...agent-tooling/src/main/java/datadog/trace/agent/tooling/bytebuddy/DDCachingPoolStrategy.java
Show resolved
Hide resolved
final Cache<TypeCacheKey, TypePool.Resolution> sharedResolutionCache = | ||
CacheBuilder.newBuilder() | ||
.softValues() | ||
final ConcurrentMap<TypeCacheKey, TypePool.Resolution> sharedResolutionCache = | ||
new ConcurrentLinkedHashMap.Builder<TypeCacheKey, TypePool.Resolution>() | ||
.maximumWeightedCapacity(TYPE_CAPACITY) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worth doing a perf test before/after this change?
Fixes #2073 |
Hi @randomanderson - I think everything should now be in place to switch Caffeine over to our own scheduler. I've been testing this in #2109 - if you rebase this PR on latest master and cherry-pick these two commits, CI should pass:
The last commit is the smallest way I found to safely patch the offending task that extends |
…g ForkJoinTask before instrumentation is ready
1252b4e
to
4798688
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm ok with the patch
This pull request removes the last Guava dependency for non-testing code 🎉
For weak caches:
Java 7: Use a combination of
WeakLockFree
andConcurrentLinkedHashMap
(CLHM was written by the same guy that went on to write Caffeine and is the recommended solution for < jdk8). Entries are expunged whenput
orcomputeIfAbsent
might hit capacityJava 8+: Use Caffeine
For other FIFO caches
Use
ConcurrentLinkedHashMap
. I looked at ourDDCache
implementations and they don't support this use case.Additionally, I did a small cleanup on the
WeakCache
andWeakMap
interfacesFor reference, the maps/caches in use after this PR:
WeakLockFree
orsynchronized java.util.WeakHashMap
datadog.trace.api.CHMCache
datadog.trace.api.FixedSizeCache
ConcurrentLinkedHashMap