ben-manes commented on a change in pull request #321: ACCUMULO-4641 Added 
loading to cache API
URL: https://github.com/apache/accumulo/pull/321#discussion_r150138225
 
 

 ##########
 File path: 
core/src/main/java/org/apache/accumulo/core/file/blockfile/cache/tinylfu/TinyLfuBlockCache.java
 ##########
 @@ -47,7 +47,7 @@
  * <li>Cache design: 
http://highscalability.com/blog/2016/1/25/design-of-a-modern-cache.html</li>
  * </ul>
  */
-public final class TinyLfuBlockCache implements BlockCache {
+public final class TinyLfuBlockCache extends SynchronousLoadingBlockCache 
implements BlockCache {
 
 Review comment:
   Yes, the internals are unfriendly to glance through. Sadly performant code 
with lots of features quickly becomes gnarly.
   
   A `get(k, loader)` or `Map.computeIfAbsent` delegate to an internal 
[computeIfAbsent](https://github.com/ben-manes/caffeine/blob/master/caffeine/src/main/java/com/github/benmanes/caffeine/cache/BoundedLocalCache.java#L1991)
 method. This does a non-blocking get, validates the entry if found, and does a 
blocking `computeIfAbsent` if absent or expired. This way hot entries are a 
cheap read.
   
   ConcurrentHashMap does say computations should be fast, which we propagate 
into our docs too. I take it as a good reminder than a red flag warning, since 
it will be a blocking call when computed. More along the lines of keep your 
lock hold times short, or don't abuse db transactions for batch imports, rather 
than use locks or transactions sparingly.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to