Concurrency level? #852
-
Howdy sir, I was looking at this page: https://github.com/ben-manes/caffeine/wiki/Specification I noted there was no section for 'concurrency level'? We have this in our current configuration for guava cache, and I'm betting it might be related to the use of a concurrent hash map? Maybe the implementation of caffeine doesn't use this data structure and this no longer applies, but is there something similar i should be setting? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
tldr; it is a no-op option since Java 8, so it is not exposed In Java 5's In Java 8's rewrite of Caffeine's own data structures don't require a |
Beta Was this translation helpful? Give feedback.
tldr; it is a no-op option since Java 8, so it is not exposed
In Java 5's
ConcurrentHashMap
, the table was statically divided into segments based on theconcurrencyLevel
(adjusted to a power-of-two). This was used to lock the entire segment when writing an entry that hashed into it, which led to coarse grained locking. A read is lock-free by volatile reads of a immutable snapshot linked list, so it could walk that safely. This resulted in good performance in general, but writes did not scale very well and it did not offer rich per-entry computations as it would lock too broadly. Guava adapted that by (effectively) storing a future as the entry value so that the hash table operations stay …