cockroachdb / cockroachdb/pebble

cache: investigate alternatives to CLOCK-Pro

Open
#5,030 0 comments 0 reactions 0 assignees View on GitHub
A-storage C-performance T-storage
Dominant language
Go
Stars
6k
Forks
584
Avg merge
16h 35m
Merged PRs (30d)
5

Description

The block cache currently uses [CLOCK-Pro](https://github.com/cockroachdb/pebble/blob/master/internal/cache/clockpro.go#L4-L15) for the cache eviction policy. There are a variety of newer alternatives nowadays which can achieve high hit rates, such as [adaptive Tiny-LFU](https://dl.acm.org/doi/10.1145/3274808.3274816). We should spelunk the [Otter v2](https://github.com/maypok86/otter?tab=readme-ov-file) implementation to see if there is anything worth stealing. We likely can't use Otter v2 directly for the block cache as we've taken pains to hide the majority of the memory used by the block cache from the Go GC.

We typically see high hit rates in the block cache. It is possible changing the eviction policy isn't worthwhile from a hit rate perspective. It might still be worthwhile to optimize the cache read path (e.g. by using [lossy hit buffers](https://github.com/maypok86/otter/blob/main/internal/lossy/striped.go#L51-L54)).

See https://github.com/cockroachdb/pebble/issues/4178 which indicates that our CLOCK-Pro implementation isn't following the paper.

Jira issue: PEBBLE-537

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with internal/cache/clockpro.go and review issue 4178 to understand the current CLOCK-Pro implementation and its deviations from the paper. Then inspect the linked Otter v2 implementation, including its lossy hit buffers, while considering the block cache's Go GC constraints. Done means documenting whether an alternative or read-path optimization is worthwhile based on hit-rate and performance evidence.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
databases, performance
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.