News for hackers. Stuff that matters.
Re:Caching Beyond RAM: The Case for NVMe by ec109685 on Thursday June 14, 2018 @08:52PM (#17316661)
They also talk in the paper of keeping the thrashing parts of the cache in RAM. Facebook for example calculates the effective hit rate of a larger set of items and only caches those that won’t be quickly purged out / overwritten in secondary storage.
Re:Caching Beyond RAM: The Case for NVMe by ebikelaw on Thursday June 14, 2018 @10:12PM (#17317031)
It's only four more years before the patent on adaptive replacement caching expires. Then we can use it in memcached ...
Re:Caching Beyond RAM: The Case for NVMe by NovaX on Friday June 15, 2018 @12:26PM (#17321040)
Thankfully there are better algorithms that are not encumbered. ARC is fairly memory hungry and requires a large cache to be effective. It is not as scan resistant and does not capture frequency as well as many believe. LIRS or TinyLFU based policies are what new implementations should be based on.

https://github.com/ben-manes/caffeine/wiki/Efficiency

Re:Caching Beyond RAM: The Case for NVMe by ec109685 on Friday June 15, 2018 @04:21AM (#17318286)
That’s unfortunate. It’s a natural architecture you stumble into when you have a two tier cache (was doing this 10 years ago when we had a memory mapped cache and a secondary spinning disk cache for a popular website).
Re:Caching Beyond RAM: The Case for NVMe by zaarn on Friday June 15, 2018 @03:28AM (#17318104)
There is CAR which has almost the same performance and no patent. You can use that.
Re:Caching Beyond RAM: The Case for NVMe by eternalban on Friday June 15, 2018 @09:22AM (#17319551)
Why not just use LRU?
Re:Caching Beyond RAM: The Case for NVMe by zaarn on Monday June 18, 2018 @03:44AM (#17336535)
CLOCK and CAR can perform a bit better than LRU in certain situations.

Notably, CLOCK keeps items that are accessed atleast once during a round while LRU will kick out the least accessed item.

The benefit of using CLOCK is that you don't have to maintain a list but only a ringbuffer. Removing an item for a CLOCK's buffer can be almost free if you use a single bit to indicate presence. A LRU will have to maintain some form of list, array or linked. In practise, LRU is expensive to implement while CLOCK is simple. CAR offers LRU performance with less complexity.

Re:Caching Beyond RAM: The Case for NVMe by Symmetry on Friday June 15, 2018 @11:01AM (#17320217)
Performance. The Wikipedia page on cache policies is pretty good.

https://en.wikipedia.org/wiki/Cache_replacement_policies#Clo...

Re:Caching Beyond RAM: The Case for NVMe by eternalban on Friday June 15, 2018 @06:46PM (#17324342)
Wiki says "Substantially" better than LRU but actual results seem to show performance converging to same levels the larger the cache gets. (See page 5.)

https://dbs.uni-leipzig.de/file/ARC.pdf

[p.s. there is also the matter of the (patterns in the) various trace runs. Does anyone know where these traces can be obtained?]

Re:Caching Beyond RAM: The Case for NVMe by ebikelaw on Friday June 15, 2018 @07:22PM (#17324583)
All caches have equal hit rates in the limit when the size of the cache approaches infinity. For finite caches, ARC often wins. In practical experience I've found that a weighted ARC dramatically outperformed LRU for DNS RR caching, in terms of both hit rate and raw CPU time spent per access. This is because it was easy to code an ARC cache that had lock-free access to frequently referenced items; once an item had been promoted to T2 no locks were needed for most accesses. With LRU it's necessary to have exclusive access to the entire cache in order to evict something and add something else.

Of course there are more schemes than just LRU and ARC, and one can try to employ lock-free schemes more than I'm willing to do. This is just my experience.

Re:Caching Beyond RAM: The Case for NVMe by NovaX on Friday June 15, 2018 @09:17PM (#17325179)
ARC often wins against LRU, but there is a lot of left on the table compared to other policies. That's because they do capture some frequency, but not very well imho.

You can mitigate the exclusive lock using a write-ahead log approach [1] [2]. Then you record events into ring buffers, replay in batches, and have an exclusive tryLock. This works really well in practice and lets you do much more complex policy work without much less worry about concurrency.

[1] http://highscalability.com/blog/2016/1/25/design-of-a-modern...

[2] http://web.cse.ohio-state.edu/hpcs/WWW/HTML/publications/pap...

Re:Caching Beyond RAM: The Case for NVMe by eternalban on Saturday June 16, 2018 @09:07AM (#17327240)
I don't believe the table in question appraoched "infinity". Check again.
Re:Caching Beyond RAM: The Case for NVMe by NovaX on Friday June 15, 2018 @09:12PM (#17325155)
I wrote a simulator and link to the traces. One unfortunate aspect is they did not provide a real comparison with LIRS, except in a table that includes an incorrect number. It comes off a little biased since LIRS outperforms ARC in most of their own traces.

https://github.com/ben-manes/caffeine/wiki/Simulator

Re:Caching Beyond RAM: The Case for NVMe by eternalban on Saturday June 16, 2018 @09:06AM (#17327236)
Thank you, you are awesome!
Re:Caching Beyond RAM: The Case for NVMe by ksec on Friday June 15, 2018 @12:10AM (#17317497)
Serious ? Doesn't ZFS already uses it?
Re:Caching Beyond RAM: The Case for NVMe by ebikelaw on Friday June 15, 2018 @12:51AM (#17317607)
Sun licenses the patent and has related patents on the same thing. Sun provides an implementation under the CDDL license. ZFS on Linux is distributed under the CDDL. Linux is distributed under the GPL for which no patent holders have granted permission to use the patented inventions. Many other implementations exist including one under the Apache license and one under the Mozilla license that I found in two seconds on github.

The whole thing is a mess.

Re:Caching Beyond RAM: The Case for NVMe by IcePic on Friday June 15, 2018 @03:08AM (#17318012)
I think there's only a part of ARC that was patented so if you ran the lists differently, you could basically use the double-list idea where you move entities back and forth between them as long as the lists aren't of the same kind.
Re:Caching Beyond RAM: The Case for NVMe by logophobia on Friday June 15, 2018 @04:15AM (#17318269)
I basically used a memory-weighted variant of the ARC algorithm, sufficiently different so that the patent doesn't cover it.

I imagine there are quite a couple of variants of ARC you can use without violating the patent.