Skip to content
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

Builtin costs rework #837

Merged
merged 16 commits into from
Oct 10, 2024
Merged

Builtin costs rework #837

merged 16 commits into from
Oct 10, 2024

Conversation

edg-l
Copy link
Collaborator

@edg-l edg-l commented Oct 8, 2024

Fixes #836

Checklist

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

Copy link

github-actions bot commented Oct 8, 2024

✅ Code is now correctly formatted.

Copy link

github-actions bot commented Oct 9, 2024

Benchmark results Main vs HEAD.

Command Mean [s] Min [s] Max [s] Relative
head factorial_2M.cairo (JIT) 3.147 ± 0.020 3.117 3.174 1.02 ± 0.01
base factorial_2M.cairo (JIT) 3.114 ± 0.016 3.093 3.142 1.01 ± 0.01
head factorial_2M.cairo (AOT) 3.094 ± 0.009 3.080 3.106 1.01 ± 0.01
base factorial_2M.cairo (AOT) 3.074 ± 0.017 3.048 3.103 1.00
Command Mean [s] Min [s] Max [s] Relative
head fib_2M.cairo (JIT) 2.665 ± 0.018 2.632 2.697 1.02 ± 0.01
base fib_2M.cairo (JIT) 2.653 ± 0.015 2.633 2.679 1.01 ± 0.01
head fib_2M.cairo (AOT) 2.628 ± 0.011 2.604 2.637 1.00 ± 0.01
base fib_2M.cairo (AOT) 2.625 ± 0.012 2.612 2.652 1.00
Command Mean [s] Min [s] Max [s] Relative
head logistic_map.cairo (JIT) 3.124 ± 0.020 3.098 3.148 1.06 ± 0.01
base logistic_map.cairo (JIT) 3.116 ± 0.015 3.095 3.140 1.06 ± 0.01
head logistic_map.cairo (AOT) 2.958 ± 0.016 2.929 2.989 1.01 ± 0.01
base logistic_map.cairo (AOT) 2.940 ± 0.014 2.928 2.970 1.00

@codecov-commenter
Copy link

codecov-commenter commented Oct 9, 2024

Codecov Report

Attention: Patch coverage is 84.82143% with 34 lines in your changes missing coverage. Please review.

Project coverage is 82.40%. Comparing base (82c25b3) to head (d3299d9).

Files with missing lines Patch % Lines
src/libfuncs/gas.rs 85.10% 14 Missing ⚠️
src/executor.rs 72.41% 8 Missing ⚠️
src/executor/contract.rs 70.83% 7 Missing ⚠️
src/types.rs 0.00% 3 Missing ⚠️
src/executor/jit.rs 90.00% 1 Missing ⚠️
src/utils.rs 95.65% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             main     #837    +/-   ##
========================================
  Coverage   82.39%   82.40%            
========================================
  Files         120      120            
  Lines       34605    34799   +194     
========================================
+ Hits        28513    28676   +163     
- Misses       6092     6123    +31     

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

Copy link

github-actions bot commented Oct 9, 2024

Benchmarking results

Benchmark for program factorial_2M

Open benchmarks
Command Mean [s] Min [s] Max [s] Relative
Cairo-vm (Rust, Cairo 1) 9.164 ± 0.139 9.021 9.478 19.51 ± 0.30
cairo-native (embedded AOT) 3.196 ± 0.018 3.181 3.239 6.81 ± 0.04
cairo-native (embedded JIT using LLVM's ORC Engine) 3.232 ± 0.013 3.218 3.251 6.88 ± 0.03
cairo-native (standalone AOT) 0.681 ± 0.016 0.674 0.726 1.45 ± 0.03
cairo-native (standalone AOT with -march=native) 0.470 ± 0.001 0.469 0.472 1.00

Benchmark for program fib_2M

Open benchmarks
Command Mean [s] Min [s] Max [s] Relative
Cairo-vm (Rust, Cairo 1) 9.004 ± 0.071 8.933 9.151 1128.41 ± 19.32
cairo-native (embedded AOT) 2.729 ± 0.016 2.707 2.761 341.95 ± 5.57
cairo-native (embedded JIT using LLVM's ORC Engine) 2.761 ± 0.015 2.726 2.779 346.00 ± 5.56
cairo-native (standalone AOT) 0.009 ± 0.000 0.009 0.009 1.10 ± 0.02
cairo-native (standalone AOT with -march=native) 0.008 ± 0.000 0.008 0.008 1.00

Benchmark for program logistic_map

Open benchmarks
Command Mean [s] Min [s] Max [s] Relative
Cairo-vm (Rust, Cairo 1) 4.398 ± 0.048 4.336 4.505 60.98 ± 0.67
cairo-native (embedded AOT) 3.064 ± 0.042 3.006 3.137 42.49 ± 0.58
cairo-native (embedded JIT using LLVM's ORC Engine) 3.199 ± 0.018 3.168 3.226 44.36 ± 0.27
cairo-native (standalone AOT) 0.113 ± 0.000 0.113 0.114 1.56 ± 0.00
cairo-native (standalone AOT with -march=native) 0.072 ± 0.000 0.072 0.073 1.00

@edg-l edg-l marked this pull request as ready for review October 9, 2024 17:39
programs/benches/factorial_2M.c Show resolved Hide resolved
src/compiler.rs Show resolved Hide resolved
src/executor.rs Outdated Show resolved Hide resolved
src/executor.rs Outdated Show resolved Hide resolved
src/types/builtin_costs.rs Show resolved Hide resolved
@edg-l edg-l added the review-ready A PR that is ready for review label Oct 10, 2024
CoreTypeConcrete::Circuit(CircuitTypeConcrete::MulMod(_)) => {
builtin_stats.circuit_mul = value
if let CoreTypeConcrete::BuiltinCosts(_) = type_info {
// todo: should we use this value?
Copy link
Collaborator

Choose a reason for hiding this comment

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

@edg-l Can you create an issue to track this?

@pefontana pefontana added this pull request to the merge queue Oct 10, 2024
Merged via the queue into main with commit f862ec3 Oct 10, 2024
15 checks passed
@pefontana pefontana deleted the builtin_costs branch October 10, 2024 22:17
pefontana pushed a commit that referenced this pull request Oct 18, 2024
edg-l added a commit that referenced this pull request Oct 21, 2024
* 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 <git@edgarluque.com>

* 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 <esteve.soler@lambdaclass.com>
Co-authored-by: Esteve Soler Arderiu <soler.arderiu@gmail.com>

* 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 <esteve.soler@lambdaclass.com>
Co-authored-by: Esteve Soler Arderiu <soler.arderiu@gmail.com>

* 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 <azteca1998@users.noreply.github.com>

---------

Co-authored-by: Esteve Soler Arderiu <esteve.soler@lambdaclass.com>
Co-authored-by: Esteve Soler Arderiu <soler.arderiu@gmail.com>
Co-authored-by: MrAzteca <azteca1998@users.noreply.github.com>

* 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 <limposfeed@gmail.com>

* Implement secp

* Fix bytes31

* try to fix ci (#858)

* update implementing libfuncs doc (#856)

* Fix bytes31 bug

* Remove unused dep

---------

Co-authored-by: FrancoGiachetta <francogiachetta27@gmail.com>
Co-authored-by: Edgar <git@edgarluque.com>
Co-authored-by: MrAzteca <azteca1998@users.noreply.github.com>
Co-authored-by: Esteve Soler Arderiu <esteve.soler@lambdaclass.com>
Co-authored-by: Esteve Soler Arderiu <soler.arderiu@gmail.com>
Co-authored-by: Rodrigo <rodrodpino@gmail.com>
Co-authored-by: Bohdan Ohorodnii <limposfeed@gmail.com>
@pefontana pefontana mentioned this pull request Oct 21, 2024
5 tasks
github-merge-queue bot pushed a commit that referenced this pull request Oct 21, 2024
* Revert "fix aot contract executor not passing builtinstats (#849)"

This reverts commit aff451c.

* Revert "Builtin costs rework (#837)"

This reverts commit f862ec3.

---------

Co-authored-by: pefontana <fontana.pedro93@gmail.coom>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
review-ready A PR that is ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide way to set the builtin gas cost.
4 participants