-
Notifications
You must be signed in to change notification settings - Fork 22
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
Remove expiringmap in favour of caffeine #112
Conversation
Hi @SimunKaracic thanks for proposing this PR, I thinking that using this: https://github.com/raphw/weak-lock-free/blob/master/src/main/java/com/blogspot/mydailyjava/weaklockfree/WeakConcurrentMap.java + a [pseudocode]
import com.blogspot.mydailyjava.weaklockfree.WeakConcurrentMap
private final WeakConcurrentMap<Object, TypePool.CacheProvider> cache =
new WeakConcurrentMap<Object, TypePool.CacheProvider>(false);
Executors.newScheduledThreadPoolExecutor("cache-pool-cleaner") //deamon
.scheduleWithFixedDelay(new Runnable() {
@Override
public void run() {
cache.expungeStaleEntries();
}
}, 1, 1, TimeUnit.MINUTES); |
Sure I can try to put that in and run all the tests, should be simple enough. The reason I used caffeine was because I wanted a popular, safe solution. I'll put this in, rerun all the tests, and report back! But on the final decision on this, I'll defer to your expertise |
Pushed the new version in, the deadlock tests are still running, but kamon tests pass. A couple differences:
|
Awesome! I think in relation to the point 1 we have 2 options: 1 - Keep using ExpiringMap or in both options we need shade the dependency in this manner: https://github.com/kamon-io/Kamon/blob/master/build.sbt#L339-L342 |
35ba296
to
5158aa7
Compare
@SimunKaracic done! |
🎉 I'll go on kamon next, I'll keep the expiringmap and just add it as a shaded dependency! |
Please, don't keep expiring map! We already know it has a concurrency bug in there. We should not spread the chances of that bug biting us again. |
Good point! |
The expiringMap dependency has been replaced with caffeine https://github.com/ben-manes/caffeine.
This should fix #110.
I have a small reproduction example, based on https://github.com/akka/akka-samples/tree/2.6/akka-sample-distributed-workers-scala/src/main/scala/worker, and I've been unable to get this PR to deadlock in 2k startups of the app.
All tests pass, most Kamon tests pass (expect for
kamon-annotation
, which depend onexpiringMap
being inside the kanela jar, but I have that fixed locally and can open another PR if this goes through).The only downside I see is that the agent jar file has grown in size from 5.4 MB to 6.4 MB.
Check it out and let me know what you think