Skip to content

Better MapCache concurrency#1849

Closed
xvrl wants to merge 2 commits intoapache:masterfrom
metamx:better-mapcache
Closed

Better MapCache concurrency#1849
xvrl wants to merge 2 commits intoapache:masterfrom
metamx:better-mapcache

Conversation

@xvrl
Copy link
Copy Markdown
Member

@xvrl xvrl commented Oct 23, 2015

This is a first stab at a better MapCache implementation, which uses Guava cache instead of a synchronized Map which caused bad locking behavior when closing namespaces.

Some initial benchmarking seems to indicate it may exhibit somewhat higher latencies overall, but we need more realistic workloads to tell for sure. At least the locking issue should be reduced.

fixes #1836

@xvrl xvrl added the Discuss label Oct 23, 2015
@drcrallen
Copy link
Copy Markdown
Contributor

Can this just be a new cache type instead of completely replacing the prior one?

@xvrl
Copy link
Copy Markdown
Member Author

xvrl commented Oct 23, 2015

@drcrallen if there is a good reason to keep the old one yes, but for now I'm just looking for feedback

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.

Can this be a static ImmutableMap?

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.

ImmutableMap.of() does return a static

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.

oh nice

@drcrallen
Copy link
Copy Markdown
Contributor

The reason to add new cache is to follow the "add and deprecate" method when doing features. If this was a simple modification of the prior map cache then it would make sense to just improve the prior impl. But this is essentially a re-write.

@drcrallen
Copy link
Copy Markdown
Contributor

Ok, I did some benchmarking and found that the level of concurrency in a java ConcurrentHashMap DOES have a very notable influence on its performance.... in java7

But in java8 I did not find a statistically significant difference. Good job java team on that one. ConcurrentHashMap in java 8 is leaps and bounds faster than in java7

@drcrallen drcrallen mentioned this pull request Jan 29, 2016
@binlijin
Copy link
Copy Markdown
Contributor

binlijin commented Feb 1, 2016

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.

if my understanding is correct, there is no eviction on this cache, if so, i don't see why not using a simple concurrent hash map ?

@b-slim
Copy link
Copy Markdown
Contributor

b-slim commented Feb 1, 2016

i don't see any UTs for eviction especially for the custom made weight function.

@ben-manes
Copy link
Copy Markdown

@binlijin Please consider Caffeine if this project is Java 8 based. I'd much rather see projects adopt that then CLHM, if possible. Guava's performance is sadly subpar because I punted on some important optimizations during the port and was then unsuccessful in advocating for them afterwards.

Caffeine supports all of Guava's features, has significantly higher throughput, and much better hit rate.

@drcrallen
Copy link
Copy Markdown
Contributor

@ben-manes Thanks for the info!

I'm filing an issue on the matter. Officially druid only requires java7, but there's no reason an extension would be forbidden from requiring java8.

@xvrl
Copy link
Copy Markdown
Member Author

xvrl commented Jun 28, 2016

Closing in favor of #3028

@xvrl xvrl closed this Jun 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MapCache needs re-written

6 participants