Skip to content

Conversation

roberto-bayardo
Copy link
Collaborator

@roberto-bayardo roberto-bayardo commented Jun 25, 2025

  • pool.rs: Adds a buffer pool that can be shared among cache-enabled blobs.
    • Uses the Clock cache replacement policy for lightweight LRU approximation.
    • Prevents thundering herds by limiting concurrent fetches of the same page from the underlying blob to a single task.
  • append.rs: Adds the Append blob wrapper, providing random-access read caching and write caching for blobs that can be modified only through appends.
  • tip.rs: Moves the "Buffer" from write.rs to its own module now that it's shared between Write and Append.
  • fixed.rs:
    • Changed to use Append wrappers for all blobs.
    • "Tail" blob is now maintained separately from "historical" blobs since they are subject to different invariants.
    • Added a few additional blob consistency checks in initialization.
    • Changed prune() to no longer return the actual pruning position.

@patrick-ogrady
Copy link
Contributor

patrick-ogrady commented Jun 26, 2025

I am getting the sense that "invalidating" pages if we wrap mutable buffers may not be that bad. Maybe I'm being optimistic.

This could allow us to just add Write buffers under this thing, we could just call this Read, and rename the Read to Replay.

@roberto-bayardo
Copy link
Collaborator Author

I am getting the sense that "invalidating" pages if we wrap mutable buffers may not be that bad. Maybe I'm being optimistic.

I agree, just need to potentially maintain a dirty list of pages or something like that.

This could allow us to just add Write buffers under this thing, we could just call this Read, and rename the Read to Replay.

Yes if things work out these can be combined in interesting ways.

@roberto-bayardo roberto-bayardo force-pushed the buffer-pool-work branch 12 times, most recently from ae2095b to fde1ac4 Compare July 2, 2025 01:59
@roberto-bayardo
Copy link
Collaborator Author

roberto-bayardo commented Jul 2, 2025

I am getting the sense that "invalidating" pages if we wrap mutable buffers may not be that bad. Maybe I'm being optimistic.

This could allow us to just add Write buffers under this thing, we could just call this Read, and rename the Read to Replay.

I have added a cached blob type that allows writes, but only if they are appends. It's quite lightweight, so using that even when you could use an Immutable wrapper should be fine (not have much performance impact.). This way the buffer pool need only manage read-only data, which keeps things simple & fast.

@roberto-bayardo roberto-bayardo changed the title [WiP] Buffer pool work [storage/journal/fixed & runtime/utils/buffer] buffer pool managed read caching for blobs Jul 2, 2025
@roberto-bayardo roberto-bayardo force-pushed the buffer-pool-work branch 13 times, most recently from b3b69f9 to 06a15ca Compare July 2, 2025 22:32
@patrick-ogrady patrick-ogrady merged commit 926b82b into main Jul 8, 2025
31 checks passed
@patrick-ogrady patrick-ogrady deleted the buffer-pool-work branch July 8, 2025 17:38
@codecov
Copy link

codecov bot commented Jul 8, 2025

Codecov Report

Attention: Patch coverage is 98.52476% with 14 lines in your changes missing coverage. Please review.

Project coverage is 91.45%. Comparing base (04cc0e4) to head (83161c6).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
runtime/src/utils/buffer/pool.rs 95.12% 10 Missing ⚠️
storage/src/journal/fixed.rs 98.65% 4 Missing ⚠️
@@            Coverage Diff             @@
##             main    #1157      +/-   ##
==========================================
+ Coverage   91.39%   91.45%   +0.06%     
==========================================
  Files         218      221       +3     
  Lines       59455    59938     +483     
==========================================
+ Hits        54338    54817     +479     
- Misses       5117     5121       +4     
Files with missing lines Coverage Δ
runtime/src/utils/buffer/append.rs 100.00% <100.00%> (ø)
runtime/src/utils/buffer/mod.rs 99.87% <ø> (ø)
runtime/src/utils/buffer/tip.rs 100.00% <100.00%> (ø)
runtime/src/utils/buffer/write.rs 98.79% <ø> (+5.08%) ⬆️
storage/src/adb/any.rs 99.09% <100.00%> (-0.02%) ⬇️
storage/src/adb/current.rs 96.72% <100.00%> (-0.16%) ⬇️
storage/src/index/storage.rs 99.33% <100.00%> (+<0.01%) ⬆️
storage/src/mmr/journaled.rs 98.06% <100.00%> (+<0.01%) ⬆️
storage/src/journal/fixed.rs 97.84% <98.65%> (+0.16%) ⬆️
runtime/src/utils/buffer/pool.rs 95.12% <95.12%> (ø)

... and 1 file with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 04cc0e4...83161c6. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants