Replies: 2 comments 7 replies
-
An eviction aware weight-based policy was explored in the paper Lightweight Robust Size Aware Cache Management. It showed that there was a modest hit rate benefit by taking it into account the entry's relative size. This hasn't been adopted due to personal time, the complexity in aggregating entries to evict due to concurrency, and that these scenarios are not common on the JVM. A latency-aware policy is still an immature research topic and I've shared my ideas in the past. Unfortunately there are very few workload traces to evaluate and, iirc, those papers often had to create synthetic ones. This means they are likely overfit, may generalize poorly, and could suffer from adversarial workloads or edge cases that the authors didn't imagine. I often read papers on capacity based policies that use a modest range of workloads and the proposed algorithm fails badly on a wider variety, so a feature dearth in data isn't one that makes sense to offer yet. The approach that I've proposed is to estimate the running latency distribution to derive a per-entry score relative to the average. That might use the exponential weighted moving average or exponential smoothing to help approximate the mean latency and the variance / standard deviation from it. This way one could compute the normalization (z-score, min/max), e.g. how many standard deviations the entry's load time is from the average, as a floating point value between -1.0 and +1.0, which we could map into a step-wise integer (discrete intervals). This could be used by the admission filter which determine the candidate entry's value relative to the victim to decide which to retain, where we currently rely on the aged frequency (0 to 15). By multiplying the frequency and latency scores, a popular entry that is fast to retrieve could be compared to an infrequent entry that is slow to load, and the cache predict which is more useful to keep. The attractiveness of this approach is that it is simple statistical math with low cpu and space overhead, stays relevant to the recently observed workload, and minimizes the impact of outliers. I like the above idea and I think it could work, but there are a lot of choices on which formulas to use and data would determine if one variant worked better than another. If you are interested in this feature then gathering data sets is the first hurdle where need some help. |
Beta Was this translation helpful? Give feedback.
-
Cool. That's something that @gilga1983 and @NadavKeren would probably be interested in. |
Beta Was this translation helpful? Give feedback.
-
Caffeine now supports weight based capacity, but the weight actually does not affect the evication. It's common that different elements in one cache have quite different costs to load, and i think elements with high cost should have some priority during the evication.
Beta Was this translation helpful? Give feedback.
All reactions