Skip to content

[Perf] Support fixed encoding for vqueue and other common types#4749

Merged
AhmedSoliman merged 2 commits into
mainfrom
pr4749
May 19, 2026
Merged

[Perf] Support fixed encoding for vqueue and other common types#4749
AhmedSoliman merged 2 commits into
mainfrom
pr4749

Conversation

@AhmedSoliman
Copy link
Copy Markdown
Contributor

@AhmedSoliman AhmedSoliman commented May 18, 2026

Improves decoding throughput of successive vqueue meta merge updates by ~45% as shows in the benchmark:

vqueue_meta_merge/full_merge_10000_operands
                        time:   [200.41 µs 201.33 µs 202.22 µs]
                        thrpt:  [49.451 Melem/s 49.670 Melem/s 49.897 Melem/s]
                 change:
                        time:   [-29.998% -29.504% -28.958%] (p = 0.00 < 0.05)
                        thrpt:  [+40.761% +41.852% +42.853%]
                        Performance has improved.

Stack created with Sapling. Best reviewed with ReviewStack.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 18, 2026

Test Results

  8 files  ±0    8 suites  ±0   4m 48s ⏱️ - 1m 1s
 60 tests ±0   60 ✅ ±0  0 💤 ±0  0 ❌ ±0 
267 runs  ±0  267 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit efe02e6. ± Comparison against base commit 1eaf0e0.

♻️ This comment has been updated with latest results.

@AhmedSoliman AhmedSoliman force-pushed the pr4749 branch 3 times, most recently from 70e958b to 39c8862 Compare May 18, 2026 12:37
@AhmedSoliman AhmedSoliman requested a review from muhamadazmy May 18, 2026 12:38
@AhmedSoliman AhmedSoliman marked this pull request as ready for review May 18, 2026 12:38
@AhmedSoliman AhmedSoliman requested a review from tillrohrmann May 18, 2026 12:38
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 39c88627ef

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +518 to +519
&entry_id.to_invocation_id(qid.partition_key())
.expect("This version does not support yielding vqueues entries other than invocations"),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Handle scheduler yields for non-invocation entries

This expect assumes every yielded vqueue entry is an invocation, but scheduler yields are emitted for any running head entry on leader change, and running entries can be EntryKind::StateMutation as well. In that case to_invocation_id(...) returns None and this path panics, taking down command application for an otherwise recoverable leader-change yield. Please branch by entry kind (or keep a generic yield path) instead of hard-failing here.

Useful? React with 👍 / 👎.

};
for update in batch.updates.iter() {
vqueue_meta.apply_update(update);
if let Err(err) = update.replace_from_slice(op) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve old vqueue-merge operand decoding during upgrade

The merge operator now decodes every operand as a single Update, but prior code wrote operands wrapped in VQueueMetaUpdates. During restart/rolling upgrade, existing RocksDB merge operands in the old format can still be present; replace_from_slice(op) will fail on those bytes and full_merge returns None, turning normal merge/read/compaction into merge failures. Keep a compatibility decode path for the old wrapper format until legacy operands are drained.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor

@tillrohrmann tillrohrmann left a comment

Choose a reason for hiding this comment

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

Great improvements @AhmedSoliman 🚀 LGTM. +1 for merging :-)

Comment on lines 69 to 70
#[bilrost(tag(12))]
pub(crate) avg_inbox_duration_ms: u64,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

For the averages we are keeping the varint encodings because we assume that this value is usually small and that varint encoding pays off?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I opted to make the stats cheaper to store to allow us to grow them without worrying too much about the number of them.

Succeeded,
}

mod status_bilrost_encoding {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why not just bilrost_encoding like the other places?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I want to make the enum encoding fixed (not varint) for decode efficiency purposes.

Copy link
Copy Markdown
Contributor

@muhamadazmy muhamadazmy left a comment

Choose a reason for hiding this comment

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

LGTM! I left couple of nits.

Comment thread crates/storage-api/src/vqueue_table/entry_status.rs Outdated
Comment thread crates/storage-api/src/vqueue_table/tables.rs Outdated
Comment thread crates/storage-api/src/vqueue_table/tables.rs Outdated
…l merges

Partial merges didn't add value and wasted precious CPU cycles since the updates cannot be merged
This change removes it and increase the limit of successive merges from 100 (way too low for vqueus) to 5000100 (way too low for vqueus) to 5000
which experimentally seems to be enough, but we may expose this as an advanced config option in the future if really needed.
Improves decoding throughput of successive vqueue meta merge updates by ~45% as shows in the benchmark:

```console
vqueue_meta_merge/full_merge_10000_operands
                        time:   [200.41 µs 201.33 µs 202.22 µs]
                        thrpt:  [49.451 Melem/s 49.670 Melem/s 49.897 Melem/s]
                 change:
                        time:   [-29.998% -29.504% -28.958%] (p = 0.00 < 0.05)
                        thrpt:  [+40.761% +41.852% +42.853%]
                        Performance has improved.
```
@AhmedSoliman AhmedSoliman merged commit efe02e6 into main May 19, 2026
63 of 65 checks passed
@AhmedSoliman AhmedSoliman deleted the pr4749 branch May 19, 2026 10:53
@github-actions github-actions Bot locked and limited conversation to collaborators May 19, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants