Skip to content

Conversation

patrick-ogrady
Copy link
Contributor

@patrick-ogrady patrick-ogrady commented Jul 1, 2025

Modifying 1 key on a 100, 1000, and 10000 key store takes ~roughly the same time (and modifies the same amount of data on disk):

metadata::sync/keys=100 modified=1
                        time:   [3.3392 ms 3.4057 ms 3.4644 ms]

metadata::sync/keys=1000 modified=1
                        time:   [3.2514 ms 3.3059 ms 3.3589 ms]

metadata::sync/keys=10000 modified=1
                        time:   [3.2269 ms 3.5963 ms 3.8910 ms]

@patrick-ogrady patrick-ogrady requested a review from Copilot July 1, 2025 17:42
Copilot

This comment was marked as outdated.

@patrick-ogrady patrick-ogrady changed the title [storage/metadata] Improve Delta Write Efficiency [storage/metadata] Improve Delta Write Efficiency (When Keys are Stable) Jul 1, 2025
@patrick-ogrady patrick-ogrady changed the title [storage/metadata] Improve Delta Write Efficiency (When Keys are Stable) [storage/metadata] Improve Delta Write Efficiency (When Keys and Value Length is Stable) Jul 1, 2025
@patrick-ogrady patrick-ogrady requested a review from Copilot July 1, 2025 18:10
@patrick-ogrady patrick-ogrady marked this pull request as ready for review July 1, 2025 18:10
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds delta‐write support so that when keys and value lengths remain stable, only changed segments are written in-place rather than rewriting the entire blob.

  • Tracks each key’s byte offset and length in the blob and marks modified keys
  • Implements overwrite vs. full-rewrite logic in sync(), plus metrics for overwrites and rewrites
  • Updates docs, tests, and benchmarks to reflect new behavior and renamed parameters

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
storage/src/metadata/storage.rs Added lengths and modified tracking, implemented in-place overwrite logic, updated metrics
storage/src/metadata/mod.rs Renamed docs and tests to use sync_rewrites/sync_overwrites metrics
storage/src/metadata/benches/utils.rs Renamed modified_pctmodified and updated helper function signature
storage/src/metadata/benches/sync.rs Updated benchmark loops/labels to use modified count
Comments suppressed due to low confidence (3)

storage/src/metadata/storage.rs:53

  • [nitpick] The field name key_order_changed is a bit ambiguous; consider renaming it to something like last_rewrite_version or last_key_order_change_version for greater clarity.
    key_order_changed: u64,

storage/src/metadata/benches/utils.rs:38

  • [nitpick] The comment is unclear: consider rephrasing to Modify the first <count> keys and emit a new set of key-value pairs or update to Modify modified keys to match the parameter name.
/// Modify `modified` of keys and emit a new set of keys.

storage/src/metadata/storage.rs:184

  • [nitpick] Since K implements Array and may have a fixed size, consider using K::SIZE directly instead of encode_size() to avoid potential runtime overhead.
            cursor += key.encode_size();

@patrick-ogrady patrick-ogrady changed the title [storage/metadata] Improve Delta Write Efficiency (When Keys and Value Length is Stable) [storage/metadata] Improve Delta Write Efficiency (For the Common Case where Keys and Value Length is Stable) Jul 1, 2025
@patrick-ogrady patrick-ogrady changed the title [storage/metadata] Improve Delta Write Efficiency (For the Common Case where Keys and Value Length is Stable) [storage/metadata] Improve Delta Write Efficiency for Common Case Jul 1, 2025
@patrick-ogrady patrick-ogrady merged commit e9e0731 into main Jul 1, 2025
29 checks passed
@patrick-ogrady patrick-ogrady deleted the simplify-diff-logic branch July 1, 2025 18:41
Copy link

codecov bot commented Jul 1, 2025

Codecov Report

Attention: Patch coverage is 99.35760% with 3 lines in your changes missing coverage. Please review.

Project coverage is 91.28%. Comparing base (89f2192) to head (2aafa56).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
storage/src/metadata/mod.rs 99.13% 3 Missing ⚠️
@@            Coverage Diff             @@
##             main    #1189      +/-   ##
==========================================
+ Coverage   91.22%   91.28%   +0.05%     
==========================================
  Files         216      216              
  Lines       57982    58364     +382     
==========================================
+ Hits        52896    53278     +382     
  Misses       5086     5086              
Files with missing lines Coverage Δ
storage/src/metadata/storage.rs 98.90% <100.00%> (+1.64%) ⬆️
storage/src/metadata/mod.rs 99.05% <99.13%> (+0.02%) ⬆️

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 89f2192...2aafa56. 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.

1 participant