https://github.com/bootjp/adaptsize-go
Go AdaptSize cache: size-aware admission exp(-size/c) + LRU eviction with background tuner maximizing OHR, for KVS front-ends.
https://github.com/bootjp/adaptsize-go
adaptsize admission-control cache caching kvs lru size-aware-caching
Last synced: 2 months ago
JSON representation
Go AdaptSize cache: size-aware admission exp(-size/c) + LRU eviction with background tuner maximizing OHR, for KVS front-ends.
- Host: GitHub
- URL: https://github.com/bootjp/adaptsize-go
- Owner: bootjp
- Created: 2025-11-03T10:55:26.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2025-12-24T05:38:09.000Z (6 months ago)
- Last Synced: 2025-12-25T18:52:28.123Z (6 months ago)
- Topics: adaptsize, admission-control, cache, caching, kvs, lru, size-aware-caching
- Language: Go
- Homepage:
- Size: 446 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# AdaptSize cache for Go KVS
- Admission: `P(admit) = exp(-size/c)`
- Eviction: LRU
- Background tuning: maximize OHR by grid-searching `c`; for each `c`, solve `μ` s.t. `Σ P_in(i)*s_i = K` via binary search.
## Usage
```go
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()
_ = c
```
## Acknowledgments and References
This 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 admission `exp(-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.