-
Notifications
You must be signed in to change notification settings - Fork 164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
perf: represent pc:hint mapping as a vector indexed by ranges #931
Conversation
067b99c
to
c671a90
Compare
Codecov Report
@@ Coverage Diff @@
## main #931 +/- ##
==========================================
+ Coverage 97.53% 97.89% +0.36%
==========================================
Files 92 89 -3
Lines 37474 35591 -1883
==========================================
- Hits 36549 34842 -1707
+ Misses 925 749 -176
... and 8 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Benchmark Results for unmodified programs 🚀
|
42bb627
to
ddab497
Compare
9829f65
to
35491c6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
vm/src/serde/deserialize_program.rs
Outdated
.hints_ranges | ||
.iter() | ||
.enumerate() | ||
.filter_map(|(pc, r)| r.map(|(s, l)| (pc, (s, s + l.get())))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a bit confusing, maybe a comment explaining what is happening would be useful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I'll do that, or maybe I'll see if I can make it simpler.
vm/src/serde/deserialize_program.rs
Outdated
.hints_ranges | ||
.iter() | ||
.enumerate() | ||
.filter_map(|(pc, r)| r.map(|(s, l)| (pc, (s, s + l.get())))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
This avoids costly `HashMap` queries
This avoids costly `HashMap` queries
This avoids costly `HashMap` queries
Replaces the use of
HashMap<usize, _>
to store hint data withVec<_>
andranges in the form
Vec<Option<(usize, NonZeroUsize)>>
, where the indexcorresponds to the given PC, the first field is the first index in the hints
Vec
and the second one is the length of such range.This avoids the cost of hashing and reduces memory fragmentation by collapsing
all of the individual
Vec
s of each PC into a single biggerVec
. The cost ofthis is two extra machine words per PC for storing the ranges, as well as some
increase in code complexity.
Benchmark results
In files suffixed by
-proof
additional arguments--memory_file /dev/null --trace_file /dev/null --proof_mode
are passed.-quick
runs don't generate traces nor dump memory.blake2s_integration_benchmark-proof.md
base-felt
base-bigint
ranges-felt
ranges-bigint
blake2s_integration_benchmark-quick.md
base-felt
base-bigint
ranges-felt
ranges-bigint
compare_arrays_200000-proof.md
base-felt
base-bigint
ranges-felt
ranges-bigint
compare_arrays_200000-quick.md
base-felt
base-bigint
ranges-felt
ranges-bigint
dict_integration_benchmark-proof.md
base-felt
base-bigint
ranges-felt
ranges-bigint
dict_integration_benchmark-quick.md
base-felt
base-bigint
ranges-felt
ranges-bigint
ec_op-proof.md
base-felt
base-bigint
ranges-felt
ranges-bigint
ec_op-quick.md
base-felt
base-bigint
ranges-felt
ranges-bigint
factorial_multirun-proof.md
base-felt
base-bigint
ranges-felt
ranges-bigint
factorial_multirun-quick.md
base-felt
base-bigint
ranges-felt
ranges-bigint
fibonacci_1000_multirun-proof.md
base-felt
base-bigint
ranges-felt
ranges-bigint
fibonacci_1000_multirun-quick.md
base-felt
base-bigint
ranges-felt
ranges-bigint
field_arithmetic_get_square_benchmark-proof.md
base-felt
base-bigint
ranges-felt
ranges-bigint
field_arithmetic_get_square_benchmark-quick.md
base-felt
base-bigint
ranges-felt
ranges-bigint
find_element-proof.md
find_element-quick.md
base-felt
base-bigint
ranges-felt
ranges-bigint
integration_builtins-proof.md
base-felt
base-bigint
ranges-felt
ranges-bigint
integration_builtins-quick.md
base-felt
base-bigint
ranges-felt
ranges-bigint
keccak_integration_benchmark-proof.md
base-felt
base-bigint
ranges-felt
ranges-bigint
keccak_integration_benchmark-quick.md
base-felt
base-bigint
ranges-felt
ranges-bigint
linear_search-proof.md
base-felt
base-bigint
ranges-felt
ranges-bigint
linear_search-quick.md
base-felt
base-bigint
ranges-felt
ranges-bigint
math_cmp_and_pow_integration_benchmark-proof.md
base-felt
base-bigint
ranges-felt
ranges-bigint
math_cmp_and_pow_integration_benchmark-quick.md
base-felt
base-bigint
ranges-felt
ranges-bigint
math_integration_benchmark-proof.md
base-felt
base-bigint
ranges-felt
ranges-bigint
math_integration_benchmark-quick.md
base-felt
base-bigint
ranges-felt
ranges-bigint
memory_integration_benchmark-proof.md
base-felt
base-bigint
ranges-felt
ranges-bigint
memory_integration_benchmark-quick.md
base-felt
base-bigint
ranges-felt
ranges-bigint
operations_with_data_structures_benchmarks-proof.md
base-felt
base-bigint
ranges-felt
ranges-bigint
operations_with_data_structures_benchmarks-quick.md
base-felt
base-bigint
ranges-felt
ranges-bigint
pedersen-proof.md
base-felt
base-bigint
ranges-felt
ranges-bigint
pedersen-quick.md
base-felt
base-bigint
ranges-felt
ranges-bigint
poseidon_integration_benchmark-proof.md
base-felt
base-bigint
ranges-felt
ranges-bigint
poseidon_integration_benchmark-quick.md
base-felt
base-bigint
ranges-felt
ranges-bigint
search_sorted_lower-proof.md
search_sorted_lower-quick.md
base-felt
base-bigint
ranges-felt
ranges-bigint
secp_integration_benchmark-proof.md
base-felt
base-bigint
ranges-felt
ranges-bigint
secp_integration_benchmark-quick.md
base-felt
base-bigint
ranges-felt
ranges-bigint
set_integration_benchmark-proof.md
base-felt
base-bigint
ranges-felt
ranges-bigint
set_integration_benchmark-quick.md
base-felt
base-bigint
ranges-felt
ranges-bigint
uint256_integration_benchmark-proof.md
base-felt
base-bigint
ranges-felt
ranges-bigint
uint256_integration_benchmark-quick.md
base-felt
base-bigint
ranges-felt
ranges-bigint