Skip to content

Commit

Permalink
chore(ci): Add test for global vars entry points regression (#7209)
Browse files Browse the repository at this point in the history
  • Loading branch information
vezenovm authored Jan 29, 2025
1 parent a779cef commit 784a562
Show file tree
Hide file tree
Showing 7 changed files with 3,913 additions and 3 deletions.
2 changes: 1 addition & 1 deletion test_programs/compilation_report.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ current_dir=$(pwd)
base_path="$current_dir/execution_success"

# Tests to be profiled for compilation report
tests_to_profile=("sha256_regression" "regression_4709" "ram_blowup_regression")
tests_to_profile=("sha256_regression" "regression_4709" "ram_blowup_regression" "global_var_regression_entry_points")

echo "{\"compilation_reports\": [ " > $current_dir/compilation_report.json

Expand Down
2 changes: 1 addition & 1 deletion test_programs/execution_report.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ current_dir=$(pwd)
base_path="$current_dir/execution_success"

# Tests to be profiled for execution report
tests_to_profile=("sha256_regression" "regression_4709" "ram_blowup_regression")
tests_to_profile=("sha256_regression" "regression_4709" "ram_blowup_regression" "global_var_regression_entry_points")

echo "{\"execution_reports\": [ " > $current_dir/execution_report.json

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[package]
name = "global_var_regression_entry_points"
type = "bin"
authors = [""]

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
x = 0
y = 1

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
mod consts;
use consts::EXPONENTIATE;

fn main(x: Field, y: pub Field) {
/// Safety: testing context
unsafe {
assert(entry_point_only_const_global(x) == 2);
check_acc_entry_point(x, y);
assert(entry_point_only_const_global(x) == 2);
entry_point_inner_func_globals(x as Field, y);
// NOTE: We want a lot of these calls to display clearly
// that execution time has not been tainted by accidentally initializing globals
// for entry points which do not use them.
assert(entry_point_no_globals(x, y) == 1);
assert(entry_point_no_globals(x, y) == 1);
assert(entry_point_only_const_global(x) == 2);
assert(entry_point_only_const_global(x) == 2);
assert(entry_point_only_const_global(x) == 2);
assert(entry_point_only_const_global(x) == 2);
assert(entry_point_only_const_global(x) == 2);
assert(entry_point_no_globals(x, y) == 1);
assert(entry_point_no_globals(x, y) == 1);
assert(entry_point_no_globals(x, y) == 1);
}
}

unconstrained fn check_acc_entry_point(x: Field, y: Field) {
let mut acc: Field = 0;
for i in 0..2 {
for j in 0..2 {
acc += EXPONENTIATE[i][j];
}
}
assert(!acc.lt(x));
assert(x != y);

assert(inner(x + 1) == 2);
}

fn inner(x: Field) -> Field {
x + 1
}

unconstrained fn entry_point_only_const_global(x: Field) -> Field {
inner(x + 1)
}

unconstrained fn entry_point_no_globals(x: Field, y: Field) -> Field {
x + y
}

unconstrained fn entry_point_inner_func_globals(x: Field, y: Field) {
one_more_wrapper(x, y);
}

unconstrained fn one_more_wrapper(x: Field, y: Field) {
check_acc_entry_point(x, y);
check_acc_entry_point(x, y);
check_acc_entry_point(x, y);
}
2 changes: 1 addition & 1 deletion test_programs/memory_report.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ PARSE_MEMORY=$(realpath "$(dirname "$0")/parse_memory.sh")


# Tests to be profiled for memory report
tests_to_profile=("keccak256" "workspace" "regression_4709" "ram_blowup_regression")
tests_to_profile=("keccak256" "workspace" "regression_4709" "ram_blowup_regression" "global_var_regression_entry_points")

current_dir=$(pwd)
base_path="$current_dir/execution_success"
Expand Down

1 comment on commit 784a562

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Execution Time'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.20.

Benchmark suite Current: 784a562 Previous: a779cef Ratio
sha256_regression 0.078 s 0.051 s 1.53

This comment was automatically generated by workflow using github-action-benchmark.

CC: @TomAFrench

Please sign in to comment.