- Admission:
P(admit) = exp(-size/c) - Eviction: LRU
- Background tuning: maximize OHR by grid-searching
c; for eachc, solveμs.t.Σ P_in(i)*s_i = Kvia binary search.
cache := adaptsize.New(adaptsize.Options{
CapacityBytes: 1<<30, // 1 GiB
WindowN: 250_000,
})
defer cache.Close()
// For every request, record it and decide admission on misses.
req := adaptsize.Request{Key: "k1", SizeBytes: 1234, Hit: false} // hit comes from your cache
admit := cache.Request(req)
if !req.Hit && admit {
// insert into your cache implementation
}
c := cache.ParameterC()
_ = cThis library is a reimplementation based on the formulas and design principles of AdaptSize, a paper by Akamai researchers published at NSDI 2017. We acknowledge the prior work of the authors and their institutions. This is an independent third-party implementation and is not affiliated with the paper’s authors, their institutions, or the conference.
References
- AdaptSize, Proceedings of the 14th USENIX Symposium on Networked Systems Design and Implementation (NSDI), 2017. Akamai Technologies.
Core elements in this implementation: size-aware admissionexp(-size/c), a closed-form in-cache probability derived from the theorem, solvingμfrom the capacity constraint, and a global search that maximizes OHR (Object Hit Ratio).
Notes
- The API and parameter tuning implemented here follow the paper’s model; we adopt
exp(-size/c)to match the paper’s notation. - This code is not the paper’s official implementation. Algorithmic accuracy and applicability depend on the workload.