perf: batch cost tracking for primitive vector decode#716
Merged
Conversation
Click to see raw report |
Pre-compute the total decoding cost for primitive vectors at the vector level instead of calling add_cost per element. Also sets primitive_vec_fast_path once before visit_seq rather than saving and restoring it on every element. Benchmark: vec_int16 decoding 694M → 409M instructions (41% faster). Wire format and cost accounting semantics are unchanged. Made-with: Cursor
d55bd46 to
40251ab
Compare
lwshang
approved these changes
Mar 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Pre-compute the total decoding cost for primitive vectors at the vector level instead of calling
add_costper element. Also setsprimitive_vec_fast_pathonce beforevisit_seqrather than saving and restoring it on every element.primitive_byte_costhelperlen * (3 + byte_cost)indeserialize_seqfor primitive vectorsadd_costfromprimitive_impl!anddeserialize_boolfast pathsadd_cost(3)into non-primitive branch innext_element_seedBenchmark (canbench, wasm32)
No regressions on any of the 9 benchmarks.
Compatibility
Wire format and cost accounting semantics are unchanged. The total cost charged is identical — it's just computed once upfront instead of incrementally.
Relates to #710