Skip to content

perf: split admission and eviction locks#489

Open
huynhanx03 wants to merge 1 commit into
dgraph-io:mainfrom
huynhanx03:develop
Open

perf: split admission and eviction locks#489
huynhanx03 wants to merge 1 commit into
dgraph-io:mainfrom
huynhanx03:develop

Conversation

@huynhanx03

@huynhanx03 huynhanx03 commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Split the policy lock into independent admission and eviction locks. This prevents eviction work in Add from blocking TinyLFU frequency updates in processItems and allows eviction metadata reads to run concurrently.

Changes

  • Protect TinyLFU with admitMu and sampledLFU with evictMu.
  • Release the eviction lock before frequency estimation and validate sampled victims before deletion.
  • Add concurrency tests and focused policy benchmarks.

Benchmark

CPU: Apple M5 (darwin / arm64)

Name Before After Change
ProcessItems 301.1 ns/op 311.4 ns/op +3.4%
ProcessItemsDuringEviction 47,031 ns/op 431.5 ns/op -99.1%
Frequency throughput during eviction 85,050 keys/s 9,270,112 keys/s 109x
Concurrent Has 164.6 ns/op 122.9 ns/op -25.3%
Concurrent Cost 145.2 ns/op 103.4 ns/op -28.8%
Concurrent Cap 102.1 ns/op 77.43 ns/op -24.2%
Add with eviction 908.1 ns/op 1,079 ns/op +18.8%

Checklist

  • Code compiles correctly and linting passes locally
  • Tests added for new functionality, or regression tests for bug fixes added as applicable

@huynhanx03 huynhanx03 requested a review from a team as a code owner June 27, 2026 02:55
@huynhanx03

Copy link
Copy Markdown
Contributor Author

Hi @mangalaman93 , could you review, thanks.

@huynhanx03

Copy link
Copy Markdown
Contributor Author

Hi @matthewmcneely, help me pls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant