ConCurrentLinkedHashMap

0 views
Skip to first unread message

Noble

unread,
Jul 28, 2008, 2:38:12 PM7/28/08
to Google Collections Library - developer list
Do we have any datastructure that can be used as a ThreadSafe version
of LinkedHashMap? The problem with LinkedHashMap is that both get()
and put() have to be synchronized which is too expensive for
implementing an Cache which evicts LRU objects

Jared Levy

unread,
Jul 28, 2008, 2:56:25 PM7/28/08
to Noble, Google Collections Library - developer list
We don't have a class of that sort.

kevin bourrillion

unread,
Jul 28, 2008, 3:09:39 PM7/28/08
to Noble, Google Collections Library - developer list
Have you confirmed that contention for your synchronized LHM is actually a bottleneck in practice?

I'm not aware if anyone's come up with a good solution for a concurrent LRU cache.  It's certainly nonobvious how it would be done.  Can you use soft references (say, with our ReferenceMap) instead?




On Mon, Jul 28, 2008 at 11:38 AM, Noble <noble...@gmail.com> wrote:



--
Kevin Bourrillion @ Google
internal: go/javalibraries
google-collections.googlecode.com
google-guice.googlecode.com

Noble

unread,
Jul 29, 2008, 12:30:02 AM7/29/08
to Google Collections Library - developer list
We have a very heavily hit cache so this has turned out to be a huge
bottleneck in our usecase.

SoftRerence is not relevant here I guess

On Jul 29, 12:09 am, "kevin bourrillion" <kev...@google.com> wrote:
> Have you confirmed that contention for your synchronized LHM is actually a
> bottleneck in practice?
>
> I'm not aware if anyone's come up with a good solution for a concurrent LRU
> cache.  It's certainly nonobvious how it would be done.  Can you use soft
> references (say, with our ReferenceMap) instead?
>

Noble

unread,
Aug 19, 2008, 2:04:16 PM8/19/08
to Google Collections Library - developer list
I have written a ConcurrentLRUCache for our own purposes using
ConcurrentHashMap.I can contribute it here if needed

Jared Levy

unread,
Aug 19, 2008, 5:56:13 PM8/19/08
to Noble, Google Collections Library - developer list
Thanks for the offer!

We already have a caching library, which includes multiple LRU caches,
in Google's internal code base. We may open-source that library at
some point, but we don't have any plans to do so. Before accepting any
contributions, we should clean up and release our current caching
code.

Jared

Jed Wesley-Smith

unread,
Aug 19, 2008, 10:24:06 PM8/19/08
to Google Collections Library - developer list
On Aug 20, 7:56 am, "Jared Levy" <jared.l.l...@gmail.com> wrote:
> We already have a caching library, which includes multiple LRU caches,
> in Google's internal code base. We may open-source that library at
> some point, but we don't have any plans to do so. Before accepting any
> contributions, we should clean up and release our current caching
> code.

Erm, you're comments are a bit contradictory. You don't plan to
release your caching libs and you won't accept any contributions as
you already have internal versions. That is all well and good for
Google projects I guess.

Noble, I for one would be very interested in your ConcurrentLRUCache.
I have written a version of one myself, but I haven't had enough time
to write a comprehensive test suite for it - and to be honest I am not
that happy with it atm. If GCollect isn't the place for it, maybe
consider another OS project such as Commons Collections?

cheers,
jed.

Noble

unread,
Aug 20, 2008, 12:54:06 AM8/20/08
to Google Collections Library - developer list
I guess commons collections use java 1.4 mine works only on java 5

On Aug 20, 7:24 am, Jed Wesley-Smith <jed.wesleysm...@gmail.com>
wrote:

Noble

unread,
Aug 20, 2008, 12:54:06 AM8/20/08
to Google Collections Library - developer list
I guess commons collections use java 1.4 mine works only on java 5

On Aug 20, 7:24 am, Jed Wesley-Smith <jed.wesleysm...@gmail.com>
wrote:

Jared Levy

unread,
Aug 20, 2008, 4:06:02 PM8/20/08
to Jed Wesley-Smith, Google Collections Library - developer list

Jed, I understand your frustration. Google has some libraries that
would be useful to you, but we're aren't making them publicly
available.

There's a lot of stuff we'd like to open-source, if we ever find the
time. Sorry about the inconvenience.

Jared

Jed Wesley-Smith

unread,
Aug 20, 2008, 8:55:13 PM8/20/08
to Jared Levy, Google Collections Library - developer list
Hi, Jared.

On 21/08/2008, at 6:06 AM, Jared Levy wrote:

> Jed, I understand your frustration. Google has some libraries that
> would be useful to you, but we're aren't making them publicly
> available.

Understand that, I am certainly not under the impression that Google
would or should use gcoll to open source everything you have - as
attractive as that may be for us :-)

The frustration is that something difficult that seems a good fit for
gcoll like a an LRU ConcurrentMap would not even be considered (I
haven't seen the implementation so I have no opinion on its quality).
The other frustration is I have a clear an pressing need for such a
beast right now ;-)

> There's a lot of stuff we'd like to open-source, if we ever find the
> time. Sorry about the inconvenience.

S'orright, thanks for the reply.

cheers,
jed.

Reply all
Reply to author
Forward
0 new messages