Skip to content

[DNM] Trace Dump Feature #1077

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

Draft
wants to merge 59 commits into
base: main
Choose a base branch
from
Draft

[DNM] Trace Dump Feature #1077

wants to merge 59 commits into from

Conversation

JulianGCalderon
Copy link
Contributor

@JulianGCalderon JulianGCalderon commented Jan 30, 2025

This PR is related to #775
It updates it with recent changes but is also not mergeable until more cleanup is done

Checklist

  • Linked to Github Issue
  • Unit tests added
  • Integration tests added.
  • This change requires new documentation.
    • Documentation has been added/updated.

azteca1998 and others added 29 commits August 28, 2024 22:44
* Impl ClassHash and SegmentArena

* Add trace dump support to compiler

* Reset workflows

* Update lock

* Implement BoundedInt

* Fix Enum trace dump

* Make gas_metadata public

* Update deps

* Fix bug

* Move deps to optional (trace dump featire)
* Add logs

* Implement Felt252Dict trace dump

* Implement nullabel for trace dump

* Print type id

* Remove print

* add convertion for Sints

* fix mispelled types

* forgot to add feature

* change Sints value to correspond to sierra-emu

* Readd feature

* Add is_infinity field to secp256 point struct (#828)

* add is_infinity to secp point

* clean

* fix

* use same deps as blockifier

* fix

* fix layout

* fix test

* remove some brittle asserts due to random initial data when adding and muling points at infinity

* fix

* remove unused dep

* fixes, missed the value entry/output

* Reset src

* Fix warnings

* Make library public

* Use debug runtime for trace dump

* fix storage's values truncations (#839)

* fix storage's values truncations

* change implementation for i8 i16 i32 i64 too

* format

* Add ptr check to felt dict entry

* Add malloc tracing and fix more memory leaks. (#833)

* Add memory tracing.

* Partial memory fixes.

* Fix arrays.

* Simplify dictionaries. Fix false positive memory leak in dictionary drops.

* Fix zero-sized allocation. Fix warnings. More mem tracing checks.

* Fix mem tracing.

* Fix memory leak in `print` libfunc.

* Fix array slice libfunc.

* Fix starknet memory leaks.

* Fix keccak syscall.

* Fix dict get double free bug.

* Lots of memory fixes.

* More fixes.

* Fix CI.

* Remove old TODOs.

* Fix CI (again).

* Remove TODOs.

* Fix test.

* Maybe fix

* Maybe fix

* Maybe fix

* Dont panic when building circuit partial outputs

* trace dump for Sha256StateHandler

* Builtin costs rework (#837)

* Update to 2.8.4, release docs, alpha

This PR updates cairo to 2.8.4, adds some release docs and updates the
version to alpha.3 to prepare for another release.

* try fix

* cleanup ci, remove panic in link

* rename from jit to from ptr, etc

* crates.io badge

* progress

* progress

* fmt2

* progress

* progress

* fix

* fix bench

* use struct

* Fix felt252 and enum deserialization bugs. (#844)

* Fix felt252 and enum deserialization bugs.

* Fix formatting.

* Also fix the runtime.

* Fix errors.

* try to fix ci

* remove unused deps

---------

Co-authored-by: Edgar Luque <[email protected]>

* Fix trace dump type conv

* fix aot contract executor not passing builtinstats (#849)

* Fix felt252 and enum deserialization bugs.

* Fix formatting.

* Also fix the runtime.

* Fix errors.

* try to fix ci

* remove unused deps

* fix aot contract executor not passing builtinstats

---------

Co-authored-by: Esteve Soler Arderiu <[email protected]>
Co-authored-by: Esteve Soler Arderiu <[email protected]>

* Fix bug (#851)

* Also fix felt bits in starknet syscall wrappers (#853)

* Also fix felt bits in starknet syscall wrappers

* style

* missed

* fix aot contract executor not passing builtinstats (#849)

* Fix felt252 and enum deserialization bugs.

* Fix formatting.

* Also fix the runtime.

* Fix errors.

* try to fix ci

* remove unused deps

* fix aot contract executor not passing builtinstats

---------

Co-authored-by: Esteve Soler Arderiu <[email protected]>
Co-authored-by: Esteve Soler Arderiu <[email protected]>

* Fix bug (#851)

* Also fix felt bits in starknet syscall wrappers (#853)

* Also fix felt bits in starknet syscall wrappers

* style

* missed

* update version to alpha 4 (#854)

* bytes31

* Better function attributes and re-enable >O1 opt (#843)

* Fix felt252 and enum deserialization bugs.

* Fix formatting.

* Also fix the runtime.

* Fix errors.

* try to fix ci

* remove unused deps

* proper function attributes

* add proper function attrs to optimize better, add some passes, run tests with atleast some opts

* dont use remi

* oops

* maybe with opt level 3 now it works

* test

* works

* readd deleted bench

* remove dbg

* Update bench-hyperfine.sh

* fixci

* comment

* Update src/ffi.rs

Co-authored-by: MrAzteca <[email protected]>

---------

Co-authored-by: Esteve Soler Arderiu <[email protected]>
Co-authored-by: Esteve Soler Arderiu <[email protected]>
Co-authored-by: MrAzteca <[email protected]>

* Resolve `CAIRO_NATIVE_RUNTIME_LIBRARY` relative path (#841)

* feat(ffi): resolve runtime relative path using current dir

* chore: remove mentions to old runtime variable

* fix: typo

---------

Co-authored-by: Bohdan Ohorodnii <[email protected]>

* Implement secp

* Fix bytes31

* try to fix ci (#858)

* update implementing libfuncs doc (#856)

* Fix bytes31 bug

* Remove unused dep

---------

Co-authored-by: FrancoGiachetta <[email protected]>
Co-authored-by: Edgar <[email protected]>
Co-authored-by: MrAzteca <[email protected]>
Co-authored-by: Esteve Soler Arderiu <[email protected]>
Co-authored-by: Esteve Soler Arderiu <[email protected]>
Co-authored-by: Rodrigo <[email protected]>
Co-authored-by: Bohdan Ohorodnii <[email protected]>
Copy link

github-actions bot commented Jan 30, 2025

❌ Code is not formatted! Please run cargo format and push the changes.

Copy link

github-actions bot commented Feb 19, 2025

Benchmark results Main vs HEAD.

Base

Command Mean [s] Min [s] Max [s] Relative
base dict_insert.cairo (JIT) 4.709 ± 0.035 4.654 4.790 1.01 ± 0.01
base dict_insert.cairo (AOT) 4.652 ± 0.021 4.628 4.681 1.00

Head

Command Mean [s] Min [s] Max [s] Relative
head dict_insert.cairo (JIT) 4.793 ± 0.037 4.742 4.854 1.01 ± 0.01
head dict_insert.cairo (AOT) 4.746 ± 0.023 4.710 4.783 1.00

Base

Command Mean [s] Min [s] Max [s] Relative
base dict_snapshot.cairo (JIT) 4.636 ± 0.016 4.610 4.661 1.03 ± 0.01
base dict_snapshot.cairo (AOT) 4.507 ± 0.017 4.476 4.531 1.00

Head

Command Mean [s] Min [s] Max [s] Relative
head dict_snapshot.cairo (JIT) 4.702 ± 0.032 4.644 4.758 1.03 ± 0.01
head dict_snapshot.cairo (AOT) 4.562 ± 0.031 4.526 4.623 1.00

Base

Command Mean [s] Min [s] Max [s] Relative
base factorial_2M.cairo (JIT) 4.968 ± 0.019 4.938 4.995 1.00 ± 0.01
base factorial_2M.cairo (AOT) 4.947 ± 0.021 4.907 4.980 1.00

Head

Command Mean [s] Min [s] Max [s] Relative
head factorial_2M.cairo (JIT) 5.043 ± 0.040 4.987 5.126 1.02 ± 0.01
head factorial_2M.cairo (AOT) 4.967 ± 0.017 4.940 4.996 1.00

Base

Command Mean [s] Min [s] Max [s] Relative
base fib_2M.cairo (JIT) 4.512 ± 0.024 4.464 4.549 1.01 ± 0.01
base fib_2M.cairo (AOT) 4.456 ± 0.026 4.412 4.497 1.00

Head

Command Mean [s] Min [s] Max [s] Relative
head fib_2M.cairo (JIT) 4.563 ± 0.021 4.533 4.603 1.00
head fib_2M.cairo (AOT) 4.571 ± 0.024 4.547 4.614 1.00 ± 0.01

Base

Command Mean [s] Min [s] Max [s] Relative
base linear_search.cairo (JIT) 4.702 ± 0.023 4.665 4.739 1.03 ± 0.01
base linear_search.cairo (AOT) 4.562 ± 0.027 4.522 4.608 1.00

Head

Command Mean [s] Min [s] Max [s] Relative
head linear_search.cairo (JIT) 4.748 ± 0.022 4.727 4.798 1.02 ± 0.01
head linear_search.cairo (AOT) 4.635 ± 0.028 4.578 4.674 1.00

Base

Command Mean [s] Min [s] Max [s] Relative
base logistic_map.cairo (JIT) 4.793 ± 0.021 4.757 4.831 1.04 ± 0.01
base logistic_map.cairo (AOT) 4.622 ± 0.031 4.583 4.671 1.00

Head

Command Mean [s] Min [s] Max [s] Relative
head logistic_map.cairo (JIT) 4.819 ± 0.014 4.802 4.852 1.03 ± 0.01
head logistic_map.cairo (AOT) 4.674 ± 0.024 4.637 4.716 1.00

@codecov-commenter
Copy link

codecov-commenter commented Feb 19, 2025

Codecov Report

Attention: Patch coverage is 83.67347% with 8 lines in your changes missing coverage. Please review.

Project coverage is 80.35%. Comparing base (19de615) to head (2f3b224).

Files with missing lines Patch % Lines
src/compiler.rs 80.00% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1077      +/-   ##
==========================================
+ Coverage   80.34%   80.35%   +0.01%     
==========================================
  Files         110      110              
  Lines       29554    29574      +20     
==========================================
+ Hits        23745    23765      +20     
  Misses       5809     5809              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

github-actions bot commented Feb 19, 2025

Benchmarking results

Benchmark for program dict_insert

Open benchmarks
Command Mean [s] Min [s] Max [s] Relative
Cairo-vm (Rust, Cairo 1) 15.143 ± 0.046 15.073 15.232 3.22 ± 0.02
cairo-native (embedded AOT) 4.702 ± 0.029 4.639 4.729 1.00
cairo-native (embedded JIT using LLVM's ORC Engine) 4.820 ± 0.072 4.729 4.951 1.03 ± 0.02

Benchmark for program dict_snapshot

Open benchmarks
Command Mean [ms] Min [ms] Max [ms] Relative
Cairo-vm (Rust, Cairo 1) 695.1 ± 8.0 682.7 709.7 1.00
cairo-native (embedded AOT) 4672.2 ± 86.5 4523.4 4806.3 6.72 ± 0.15
cairo-native (embedded JIT using LLVM's ORC Engine) 4623.3 ± 37.5 4578.0 4687.2 6.65 ± 0.09

Benchmark for program factorial_2M

Open benchmarks
Command Mean [s] Min [s] Max [s] Relative
Cairo-vm (Rust, Cairo 1) 9.066 ± 0.107 8.895 9.309 1.75 ± 0.02
cairo-native (embedded AOT) 5.184 ± 0.035 5.131 5.255 1.00
cairo-native (embedded JIT using LLVM's ORC Engine) 5.246 ± 0.027 5.195 5.280 1.01 ± 0.01

Benchmark for program fib_2M

Open benchmarks
Command Mean [s] Min [s] Max [s] Relative
Cairo-vm (Rust, Cairo 1) 8.670 ± 0.074 8.589 8.844 1.90 ± 0.03
cairo-native (embedded AOT) 4.573 ± 0.067 4.460 4.689 1.00
cairo-native (embedded JIT using LLVM's ORC Engine) 4.729 ± 0.028 4.683 4.769 1.03 ± 0.02

Benchmark for program linear_search

Open benchmarks
Command Mean [ms] Min [ms] Max [ms] Relative
Cairo-vm (Rust, Cairo 1) 724.9 ± 5.8 717.3 733.2 1.00
cairo-native (embedded AOT) 4621.9 ± 34.6 4582.9 4697.2 6.38 ± 0.07
cairo-native (embedded JIT using LLVM's ORC Engine) 4777.6 ± 30.5 4733.3 4825.2 6.59 ± 0.07

Benchmark for program logistic_map

Open benchmarks
Command Mean [ms] Min [ms] Max [ms] Relative
Cairo-vm (Rust, Cairo 1) 452.9 ± 5.2 446.8 461.5 1.00
cairo-native (embedded AOT) 4789.7 ± 51.1 4726.3 4880.7 10.58 ± 0.17
cairo-native (embedded JIT using LLVM's ORC Engine) 5001.4 ± 56.2 4919.1 5105.0 11.04 ± 0.18

@JulianGCalderon JulianGCalderon force-pushed the trace-dump-feature branch 3 times, most recently from 8973db4 to 49e46ba Compare February 24, 2025 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants