12

我们在一个项目中使用来自https://code.google.com/p/concurrentlinkedhashmap/的ConcurrentLinkedHashMap ,我看到一个注释,它在 2010 年被集成到 Guava 的 MapMaker 和 CacheBuilder 中。信息非常简短:

将算法技术集成到 MapMaker 中将在 Google Guava r08 中发布,并且很大程度上基于此版本。

究竟是什么意思?

  • concurrentlinkedhashmap 项目似乎仍然处于活动状态。
  • 引导 Guava 缓存包是否只是一次性集成?
  • 自 2010 年以来,这两个项目是否独立发展?
  • 如果是这样,今天它们之间的主要区别是什么?
4

1 回答 1

37

What does it mean exactly?

Guava is the long term replacement and most of the time you should use it. The history is that ConcurrentLinkedHashMap figured out the algorithms, Guava subsumed it, and then focused on adding features.

The concurrentlinkedhashmap project seems to be still active.

It has always been a weekend project, so active means that I have a scratch to itch or responded to a change request. It is also easier to experiment in CLHM than Guava, so I tended to prove out ideas there prior us porting them over. My involvement with Guava was as a 20%-er.

Was it just a one time integration to bootstrap the Guava cache package?

Yes. We first overhauled MapMaker and then split out caching into a dedicated API. It is a one-way migration of ideas and improvements into Guava.

Have the two projects evolved independently since 2010?

Both have stayed dedicated to their goals. The motivation behind ConcurrentLinkedHashMap was to figure out how to write a truly concurrent cache without taking shortcuts. The goal behind Guava is to provide a feature rich library with a beautiful API and solid implementation for broad usage.

What are the main differences between them today?

Guava is packed with features and has a full time team at Google supporting it. Use it!

ConcurrentLinkedHashMap has higher absolute concurrency by decorating, instead of forking, ConcurrentHashMap. This allows it to be used with ConcurrentHashMapV8, which is based on a new algorithm. CLHM does not relying on segment locks, which improves write performance and allows for maintaining a single LRU chain. I have an experimental branch with the LIRS policy that I hope to someday finish.

The long term hope is that Doug Lea will one day write a cache inspired by our work and teach us a few things in the process.


Update (3/15): Caffeine is a Java 8 rewrite of Guava's cache. It tries to provide the best of ConcurrentLinkedHashMap and Guava, modernized with Java 8, and adopting the techniques that I've learned since those previous projects.

于 2013-03-08T23:42:43.817 回答