From: Ben Manes <ben.manes@gmail.com>
To: pgsql-jdbc@postgresql.org
Subject: Re: Adding new dependencies for in-core
Date: Thu, 2 Jul 2015 22:26:09 +0000 (UTC)
Message-ID: <loom.20150703T001258-121@post.gmane.org> (raw)
References: <CAB=Je-GR+Qs85tUsGAD+5UtyTgYPdAvb8NOmThni5heUhOzT+Q@mail.gmail.com>
<011501d0b357$26f1eca0$74d5c5e0$@eu>
<3A641C7E-04D2-4554-8CDC-37A11E0178AB@gmail.com>
<013001d0b35e$253ae9a0$6fb0bce0$@eu>
<0DC27A9D-1556-427B-91FF-4D4FBD1F52E2@gmail.com>
<CAB=Je-Eo=ihwhxGZXE=AJZpE0Qviu52t4Avv-d2-3YZLATr0fw@mail.gmail.com>
<6BD778EF-0D5A-4293-8A08-723903A5FB44@gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-jdbc>
Steven Schlansker <stevenschlansker <at> gmail.com> writes:
> On Jun 30, 2015, at 11:14 AM, Vladimir Sitnikov wrote:
>
> Final note, is a ConcurrentLinkedHashMap actually the data structure we
> should be using? The "linked" part enforces that the removal strategy is
> not LRU, it is actually FIFO. So an incoming query may evict the oldest
> entry, which could very well be the most used entry. Maybe this is not a
> problem in practice but I thought I'd point it out.
CLHM evicts by LRU. Java's LinkedHashMap may be configured in either insertion
order (FIFO) or access order (LRU). The concurrent version provides only the
access order as it is intended to be used as a cache. So the eviction is
smart, as much as an LRU can be.
CLHM is really easy to shade (as many do), fork (as some do), and is pretty
tiny. An LRU policy is surprisingly tricky to implement fully concurrently,
because every read is in fact a write. This is solved by borrowing an idea
from Postgres - the write ahead log. The reads are recorded cheaply and
replayed in batches so that reads and writes may operate concurrently.
The successor project, Caffeine, includes a design document that describes a
similar approach, with some additional optimizations. Also see the benchmarks.
That cache is heavier (JAR size) due to providing a richer feature set.
Cheers,
Ben (author)
https://github.com/ben-manes/caffeine/wiki/Designhttps://github.com/ben-manes/caffeine/wiki/Benchmarks
--
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: ben.manes@gmail.com
Subject: Re: Adding new dependencies for in-core
In-Reply-To: <loom.20150703T001258-121@post.gmane.org>
References: <CAB=Je-GR+Qs85tUsGAD+5UtyTgYPdAvb8NOmThni5heUhOzT+Q@mail.gmail.com> <011501d0b357$26f1eca0$74d5c5e0$@eu> <3A641C7E-04D2-4554-8CDC-37A11E0178AB@gmail.com> <013001d0b35e$253ae9a0$6fb0bce0$@eu> <0DC27A9D-1556-427B-91FF-4D4FBD1F52E2@gmail.com> <CAB=Je-Eo=ihwhxGZXE=AJZpE0Qviu52t4Avv-d2-3YZLATr0fw@mail.gmail.com> <6BD778EF-0D5A-4293-8A08-723903A5FB44@gmail.com> <loom.20150703T001258-121@post.gmane.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox