LearnedCache:
ML-driven Page Cache Eviction Policies with eBPF
Jayden (Zejia) Qi
Eviction Policies
Eviction Policies
... many of them
There is no "one-size-fits-all"
There is no "one-size-fits-all"
But maybe it's possible
eBPF (Extended Berkeley Package Filter)
Provides a way for user-created eBPF programs to run as eviction policies.
SEC(".struct_ops.link")
struct cache_ext_ops fifo_ops = {
.init = (void *)fifo_init,
.evict_folios = (void *)fifo_evict_folios,
.folio_evicted = (void *)fifo_folio_evicted,
.folio_added = (void *)fifo_folio_added,
};void BPF_STRUCT_OPS(fifo_evict_folios, struct cache_ext_eviction_ctx *eviction_ctx,
struct mem_cgroup *memcg)
{
u64 lat_start = bpf_ktime_get_ns();
if (bpf_cache_ext_list_iterate(memcg, main_list, bpf_fifo_evict_cb, eviction_ctx) < 0)
bpf_printk("cache_ext: evict: Failed to iterate main_list\n");
}LearnedCache
Framing the decision
Given a page at eviction time, will it be accessed within a set amount of time later?
Tracers
Tracers (bolted onto FIFO policy) collect:
Model: Simple perceptron
Model: Simple perceptron
Policies: Rank or Protect
Evaluation
Evaluation - YSCB
Evaluation - Latency
Evaluation - Twitter Traces
Reflection, Limitations, Future Work
github.com/JayAndJef