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

Implement libfunc profiler. #946

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Implement libfunc profiler. #946

wants to merge 6 commits into from

Conversation

azteca1998
Copy link
Collaborator

@azteca1998 azteca1998 commented Nov 27, 2024

Implementation of a libfunc profiler.

For each executed libfunc, generates:

  • Number of samples.
  • Total number of ticks.
  • Average number of ticks.
  • Standard deviation.
  • Quartiles (0%, 25%, 50%, 75%, 100%).

Also implements an outlier detection system to filter out operating system noise.

Note: The x86_64 architecture handles context switches between cores correctly, but in aarch64 this is impossible. Results may not be reliable in aarch64.

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 Nov 27, 2024

Benchmarking results

Benchmark for program dict_insert

Open benchmarks
Command Mean [s] Min [s] Max [s] Relative
Cairo-vm (Rust, Cairo 1) 20.818 ± 0.277 20.553 21.515 5.50 ± 0.09
cairo-native (embedded AOT) 3.786 ± 0.036 3.739 3.832 1.00
cairo-native (embedded JIT using LLVM's ORC Engine) 3.932 ± 0.038 3.878 3.991 1.04 ± 0.01

Benchmark for program dict_snapshot

Open benchmarks
Command Mean [s] Min [s] Max [s] Relative
Cairo-vm (Rust, Cairo 1) 5.988 ± 0.128 5.798 6.190 1.59 ± 0.04
cairo-native (embedded AOT) 3.762 ± 0.050 3.679 3.810 1.00
cairo-native (embedded JIT using LLVM's ORC Engine) 3.855 ± 0.076 3.730 3.990 1.02 ± 0.02

Benchmark for program factorial_2M

Open benchmarks
Command Mean [s] Min [s] Max [s] Relative
Cairo-vm (Rust, Cairo 1) 14.281 ± 0.121 14.057 14.477 3.51 ± 0.06
cairo-native (embedded AOT) 4.065 ± 0.059 3.966 4.161 1.00
cairo-native (embedded JIT using LLVM's ORC Engine) 4.116 ± 0.044 4.073 4.190 1.01 ± 0.02

Benchmark for program fib_2M

Open benchmarks
Command Mean [s] Min [s] Max [s] Relative
Cairo-vm (Rust, Cairo 1) 14.274 ± 0.075 14.163 14.406 3.99 ± 0.03
cairo-native (embedded AOT) 3.578 ± 0.025 3.545 3.617 1.00
cairo-native (embedded JIT using LLVM's ORC Engine) 3.684 ± 0.042 3.619 3.743 1.03 ± 0.01

Benchmark for program linear_search

Open benchmarks
Command Mean [s] Min [s] Max [s] Relative
Cairo-vm (Rust, Cairo 1) 5.846 ± 0.039 5.775 5.895 1.59 ± 0.02
cairo-native (embedded AOT) 3.666 ± 0.029 3.623 3.703 1.00
cairo-native (embedded JIT using LLVM's ORC Engine) 3.865 ± 0.030 3.816 3.910 1.05 ± 0.01

Benchmark for program logistic_map

Open benchmarks
Command Mean [s] Min [s] Max [s] Relative
Cairo-vm (Rust, Cairo 1) 5.818 ± 0.044 5.752 5.893 1.52 ± 0.02
cairo-native (embedded AOT) 3.819 ± 0.043 3.776 3.891 1.00
cairo-native (embedded JIT using LLVM's ORC Engine) 3.889 ± 0.044 3.826 3.972 1.02 ± 0.02

Copy link

github-actions bot commented Nov 27, 2024

Benchmark results Main vs HEAD.

Base

Command Mean [s] Min [s] Max [s] Relative
base dict_insert.cairo (JIT) 3.852 ± 0.025 3.808 3.890 1.02 ± 0.01
base dict_insert.cairo (AOT) 3.759 ± 0.018 3.738 3.802 1.00

Head

Command Mean [s] Min [s] Max [s] Relative
head dict_insert.cairo (JIT) 3.820 ± 0.015 3.798 3.841 1.02 ± 0.01
head dict_insert.cairo (AOT) 3.753 ± 0.041 3.685 3.825 1.00

Base

Command Mean [s] Min [s] Max [s] Relative
base dict_snapshot.cairo (JIT) 3.730 ± 0.040 3.688 3.824 1.03 ± 0.01
base dict_snapshot.cairo (AOT) 3.613 ± 0.022 3.583 3.649 1.00

Head

Command Mean [s] Min [s] Max [s] Relative
head dict_snapshot.cairo (JIT) 3.740 ± 0.038 3.674 3.800 1.02 ± 0.02
head dict_snapshot.cairo (AOT) 3.677 ± 0.042 3.617 3.725 1.00

Base

Command Mean [s] Min [s] Max [s] Relative
base factorial_2M.cairo (JIT) 4.053 ± 0.018 4.019 4.075 1.00 ± 0.01
base factorial_2M.cairo (AOT) 4.048 ± 0.019 4.025 4.082 1.00

Head

Command Mean [s] Min [s] Max [s] Relative
head factorial_2M.cairo (JIT) 4.069 ± 0.031 4.039 4.144 1.00
head factorial_2M.cairo (AOT) 4.095 ± 0.054 3.994 4.168 1.01 ± 0.02

Base

Command Mean [s] Min [s] Max [s] Relative
base fib_2M.cairo (JIT) 3.599 ± 0.027 3.561 3.657 1.01 ± 0.01
base fib_2M.cairo (AOT) 3.569 ± 0.021 3.535 3.595 1.00

Head

Command Mean [s] Min [s] Max [s] Relative
head fib_2M.cairo (JIT) 3.651 ± 0.040 3.594 3.718 1.01 ± 0.02
head fib_2M.cairo (AOT) 3.599 ± 0.040 3.541 3.664 1.00

Base

Command Mean [s] Min [s] Max [s] Relative
base linear_search.cairo (JIT) 3.842 ± 0.033 3.798 3.901 1.04 ± 0.01
base linear_search.cairo (AOT) 3.686 ± 0.025 3.646 3.738 1.00

Head

Command Mean [s] Min [s] Max [s] Relative
head linear_search.cairo (JIT) 3.841 ± 0.026 3.810 3.896 1.03 ± 0.01
head linear_search.cairo (AOT) 3.733 ± 0.023 3.691 3.769 1.00

Base

Command Mean [s] Min [s] Max [s] Relative
base logistic_map.cairo (JIT) 3.905 ± 0.027 3.873 3.942 1.04 ± 0.01
base logistic_map.cairo (AOT) 3.767 ± 0.035 3.720 3.818 1.00

Head

Command Mean [s] Min [s] Max [s] Relative
head logistic_map.cairo (JIT) 3.910 ± 0.023 3.873 3.936 1.03 ± 0.01
head logistic_map.cairo (AOT) 3.800 ± 0.029 3.737 3.824 1.00

@codecov-commenter
Copy link

codecov-commenter commented Nov 27, 2024

Codecov Report

Attention: Patch coverage is 83.11258% with 51 lines in your changes missing coverage. Please review.

Project coverage is 80.80%. Comparing base (c55c20b) to head (edabf00).

Files with missing lines Patch % Lines
src/libfuncs/starknet.rs 23.80% 32 Missing ⚠️
src/libfuncs/bounded_int.rs 52.94% 8 Missing ⚠️
src/libfuncs/cast.rs 72.72% 3 Missing ⚠️
src/libfuncs/int_range.rs 50.00% 3 Missing ⚠️
src/libfuncs/coupon.rs 0.00% 2 Missing ⚠️
src/libfuncs/enum.rs 66.66% 2 Missing ⚠️
src/libfuncs/bytes31.rs 75.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             main     #946    +/-   ##
========================================
  Coverage   80.80%   80.80%            
========================================
  Files         109      109            
  Lines       29784    29666   -118     
========================================
- Hits        24067    23973    -94     
+ Misses       5717     5693    -24     

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

@azteca1998 azteca1998 marked this pull request as ready for review December 5, 2024 14:25
@JulianGCalderon JulianGCalderon added the review-ready A PR that is ready for review label Dec 9, 2024
@azteca1998 azteca1998 force-pushed the add-libfunc-profiling branch from f711785 to 43dde6e Compare February 18, 2025 15:35
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.

4 participants