-
Notifications
You must be signed in to change notification settings - Fork 47
Add compilation stats #1339
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
base: main
Are you sure you want to change the base?
Add compilation stats #1339
Conversation
Benchmark results Main vs HEAD.Base
Head
Base
Head
Base
Head
Base
Head
Base
Head
Base
Head
|
Benchmarking resultsBenchmark for program
|
Command | Mean [s] | Min [s] | Max [s] | Relative |
---|---|---|---|---|
Cairo-vm (Rust, Cairo 1) |
11.608 ± 0.080 | 11.505 | 11.754 | 2.18 ± 0.03 |
cairo-native (embedded AOT) |
5.317 ± 0.071 | 5.234 | 5.462 | 1.00 |
cairo-native (embedded JIT using LLVM's ORC Engine) |
5.416 ± 0.047 | 5.315 | 5.480 | 1.02 ± 0.02 |
Benchmark for program dict_snapshot
Open benchmarks
Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
---|---|---|---|---|
Cairo-vm (Rust, Cairo 1) |
879.5 ± 13.2 | 860.0 | 899.6 | 1.00 |
cairo-native (embedded AOT) |
5152.8 ± 70.8 | 5043.4 | 5259.7 | 5.86 ± 0.12 |
cairo-native (embedded JIT using LLVM's ORC Engine) |
5170.2 ± 78.2 | 5038.6 | 5287.7 | 5.88 ± 0.13 |
Benchmark for program factorial_2M
Open benchmarks
Command | Mean [s] | Min [s] | Max [s] | Relative |
---|---|---|---|---|
Cairo-vm (Rust, Cairo 1) |
5.387 ± 0.046 | 5.315 | 5.466 | 1.00 |
cairo-native (embedded AOT) |
5.479 ± 0.081 | 5.390 | 5.635 | 1.02 ± 0.02 |
cairo-native (embedded JIT using LLVM's ORC Engine) |
5.511 ± 0.043 | 5.436 | 5.577 | 1.02 ± 0.01 |
Benchmark for program fib_2M
Open benchmarks
Command | Mean [s] | Min [s] | Max [s] | Relative |
---|---|---|---|---|
Cairo-vm (Rust, Cairo 1) |
5.183 ± 0.061 | 5.130 | 5.347 | 1.05 ± 0.02 |
cairo-native (embedded AOT) |
4.918 ± 0.047 | 4.829 | 4.979 | 1.00 |
cairo-native (embedded JIT using LLVM's ORC Engine) |
4.966 ± 0.070 | 4.876 | 5.071 | 1.01 ± 0.02 |
Benchmark for program linear_search
Open benchmarks
Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
---|---|---|---|---|
Cairo-vm (Rust, Cairo 1) |
858.4 ± 14.8 | 838.1 | 875.4 | 1.00 |
cairo-native (embedded AOT) |
5017.4 ± 78.7 | 4913.2 | 5120.7 | 5.84 ± 0.14 |
cairo-native (embedded JIT using LLVM's ORC Engine) |
5235.3 ± 93.9 | 5073.7 | 5360.2 | 6.10 ± 0.15 |
Benchmark for program logistic_map
Open benchmarks
Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
---|---|---|---|---|
Cairo-vm (Rust, Cairo 1) |
558.8 ± 6.4 | 552.0 | 570.5 | 1.00 |
cairo-native (embedded AOT) |
5097.5 ± 56.2 | 5001.5 | 5189.4 | 9.12 ± 0.15 |
cairo-native (embedded JIT using LLVM's ORC Engine) |
5313.8 ± 51.5 | 5241.8 | 5384.3 | 9.51 ± 0.14 |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1339 +/- ##
==========================================
- Coverage 79.16% 78.81% -0.36%
==========================================
Files 111 111
Lines 30440 30578 +138
==========================================
Hits 24099 24099
- Misses 6341 6479 +138 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
I don't like the idea of saving max values as statistics. Maybe a contract can have one really big function and a lot of small functions, while other contract have a lot of medium functions. The max value wouldn't be too significant. I would try to save the full data in every case, and not some aggregated value. If this ends up being too much data, we could have at least a more accurate representation of the distribution (like some percentiles/quartiles). Is there a way to link declaration with usage? For example:
Is there a way to record this information? We need to find some value/set of values that predicts with acceptable accuracy the compilation effort, and I feel like that involves "combining" different metrics together. What do you think? |
let type_id = type_declaration.id.to_string(); | ||
let type_size = type_concrete.layout(®istry).unwrap().size(); | ||
if !type_concrete.is_builtin() { | ||
// We dont want to add the builtins to the stats |
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.
Why are builtins skipped?
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.
I figured they are always the same size. So I though it didn't make much sense to have them.
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.
Its not worth treating them any differently. There are many types that are always the same size (i.e. u8). I would keep them, it would also make the code a bit simpler.
Co-authored-by: Julian Gonzalez Calderon <gonzalezcalderonjulian@gmail.com>
Co-authored-by: Julian Gonzalez Calderon <gonzalezcalderonjulian@gmail.com>
@@ -416,6 +423,20 @@ pub fn layout_repeat(layout: &Layout, n: usize) -> Result<(Layout, usize), Layou | |||
Ok((layout, padded_size)) | |||
} | |||
|
|||
/// Gets the size of the full set of params of a Sierra function |
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.
nit: we can use any type, not just the params of a function, so we could update the documentation to be more generic.
/// Gets the size of the full set of params of a Sierra function | |
/// Returns the total layout size for the given types. |
/// - params_total_size: Total size of all the params | ||
/// - return_types_total_size: Total size of all the params |
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.
Please move each bullet point to the appropiate field doc comment. Idem for the other struct.
Something like:
/// Contains the following stats about a Sierra function:
pub struct SierraFuncStats {
/// Total size of all the params
pub params_total_size: usize,
/// Total size of all the params
pub return_types_total_size: usize,
pub times_used: usize,
}
/// Number of times each circuit gate is used. | ||
sierra_circuit_gates_count: CircuitGatesStats, |
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.
Shouldn't this field be public?
We have contracts that take quite a bit of time to compile. To understand why this is happening we want to add more compilation stats.
Added stats:
sierra_declared_types_stats
: Contains the stats for each Sierra declared typesierra_func_stats
: Stats about params and return types of each Sierra functionsierra_circuit_gates_count
: Number of times each circuit gate is usedChecklist