infinispan/infinispan — pull request #1282 by kblees (2012-09-04 11:56:07+00:00)
Title: Faster FileCacheStore implementation

Hi Infinispan dev team,

I recently tried to switch from Ehcache to Infinispan (mostly due to Ehcache's ingenuous 'probabilistic' (i.e. random) eviction algorithms).

However, unfortunately, I found Infinispan's FileCacheStore to be so horribly slow that is is unusable. Looking at the code, the theoretical 4 million open files per FileCacheStore prevent use in a production environment anyway.

So, I went ahead and wrote my own version, which manages cache values in a single file and keeps keys and file positions in memory. This version is ~1500 [1] to ~5000 [2] times faster than the original.

[1] with Long keys increasing in 1k steps (i.e. original FileCacheStore stores 1 entry per bucket, 1 file per entry)
[2] with adjacent Long keys (i.e. original FileCacheStore stores 1k entries per bucket, 1 file per 1k entries)

I make this code available in the hope that it may be useful to someone, or probably even included in a future release.

Cheers,
Karsten