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

fix runtime version check #1029

Merged
merged 7 commits into from
Jan 8, 2025
Merged

fix runtime version check #1029

merged 7 commits into from
Jan 8, 2025

Conversation

FrancoGiachetta
Copy link
Contributor

When checking the runtime's version, it occurs that version's buffer does not have the same size as the target buffer. Due to this, the function copy_from_slice fails when trying to copy the contents of the version's buffer into the target's one

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 Jan 7, 2025

✅ Code is now correctly formatted.

@codecov-commenter
Copy link

codecov-commenter commented Jan 7, 2025

Codecov Report

Attention: Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.

Project coverage is 80.88%. Comparing base (bdb3f8d) to head (d0277cf).

Files with missing lines Patch % Lines
runtime/src/lib.rs 0.00% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1029   +/-   ##
=======================================
  Coverage   80.88%   80.88%           
=======================================
  Files         107      107           
  Lines       29470    29470           
=======================================
  Hits        23836    23836           
  Misses       5634     5634           

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

runtime/src/lib.rs Outdated Show resolved Hide resolved
Copy link

github-actions bot commented Jan 7, 2025

Benchmark results Main vs HEAD.

Command Mean [s] Min [s] Max [s] Relative
base dict_insert.cairo (JIT) 3.910 ± 0.026 3.871 3.954 1.00
base dict_insert.cairo (AOT) 4.068 ± 0.026 4.034 4.112 1.04 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
:--- ---: ---: ---: ---:
head dict_insert.cairo (JIT) 3.901 ± 0.028 3.868 3.954 1.00
head dict_insert.cairo (AOT) 4.023 ± 0.022 3.976 4.048 1.03 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base dict_snapshot.cairo (JIT) 4.102 ± 0.028 4.060 4.154 1.00
base dict_snapshot.cairo (AOT) 4.180 ± 0.030 4.135 4.242 1.02 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
:--- ---: ---: ---: ---:
head dict_snapshot.cairo (JIT) 4.049 ± 0.020 4.015 4.081 1.00
head dict_snapshot.cairo (AOT) 4.182 ± 0.017 4.150 4.203 1.03 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base factorial_2M.cairo (JIT) 4.074 ± 0.034 4.013 4.139 1.00
base factorial_2M.cairo (AOT) 4.282 ± 0.022 4.247 4.329 1.05 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
:--- ---: ---: ---: ---:
head factorial_2M.cairo (JIT) 4.142 ± 0.027 4.080 4.173 1.00
head factorial_2M.cairo (AOT) 4.322 ± 0.032 4.265 4.388 1.04 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base fib_2M.cairo (JIT) 3.595 ± 0.020 3.569 3.630 1.00
base fib_2M.cairo (AOT) 3.812 ± 0.025 3.761 3.853 1.06 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
:--- ---: ---: ---: ---:
head fib_2M.cairo (JIT) 3.653 ± 0.030 3.614 3.701 1.00
head fib_2M.cairo (AOT) 3.898 ± 0.049 3.842 3.977 1.07 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base linear_search.cairo (JIT) 3.782 ± 0.016 3.759 3.816 1.00
base linear_search.cairo (AOT) 3.887 ± 0.013 3.868 3.907 1.03 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
:--- ---: ---: ---: ---:
head linear_search.cairo (JIT) 3.896 ± 0.061 3.844 4.056 1.00
head linear_search.cairo (AOT) 3.924 ± 0.018 3.906 3.959 1.01 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base logistic_map.cairo (JIT) 3.899 ± 0.017 3.872 3.924 1.00
base logistic_map.cairo (AOT) 3.955 ± 0.024 3.919 4.007 1.01 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
:--- ---: ---: ---: ---:
head logistic_map.cairo (JIT) 3.905 ± 0.039 3.857 3.979 1.00
head logistic_map.cairo (AOT) 3.980 ± 0.022 3.957 4.023 1.02 ± 0.01

Copy link

github-actions bot commented Jan 7, 2025

Benchmarking results

Benchmark for program dict_insert

Open benchmarks
Command Mean [s] Min [s] Max [s] Relative
Cairo-vm (Rust, Cairo 1) 20.927 ± 0.194 20.634 21.227 97.74 ± 3.20
cairo-native (embedded AOT) 3.993 ± 0.029 3.959 4.062 18.65 ± 0.60
cairo-native (embedded JIT using LLVM's ORC Engine) 3.837 ± 0.068 3.766 3.954 17.92 ± 0.65
cairo-native (standalone AOT with -march=native) 0.214 ± 0.007 0.206 0.228 1.00

Benchmark for program dict_snapshot

Open benchmarks
Command Mean [s] Min [s] Max [s] Relative
Cairo-vm (Rust, Cairo 1) 5.810 ± 0.036 5.758 5.865 18.32 ± 0.13
cairo-native (embedded AOT) 4.167 ± 0.032 4.118 4.236 13.14 ± 0.11
cairo-native (embedded JIT using LLVM's ORC Engine) 4.090 ± 0.054 4.035 4.199 12.90 ± 0.18
cairo-native (standalone AOT with -march=native) 0.317 ± 0.001 0.316 0.319 1.00

Benchmark for program factorial_2M

Open benchmarks
Command Mean [s] Min [s] Max [s] Relative
Cairo-vm (Rust, Cairo 1) 14.850 ± 0.108 14.696 15.080 10.94 ± 0.08
cairo-native (embedded AOT) 4.270 ± 0.031 4.234 4.334 3.14 ± 0.02
cairo-native (embedded JIT using LLVM's ORC Engine) 4.168 ± 0.057 4.105 4.303 3.07 ± 0.04
cairo-native (standalone AOT with -march=native) 1.358 ± 0.001 1.356 1.359 1.00

Benchmark for program fib_2M

Open benchmarks
Command Mean [s] Min [s] Max [s] Relative
Cairo-vm (Rust, Cairo 1) 14.724 ± 0.076 14.597 14.853 183.29 ± 2.39
cairo-native (embedded AOT) 3.802 ± 0.041 3.768 3.899 47.32 ± 0.76
cairo-native (embedded JIT using LLVM's ORC Engine) 3.733 ± 0.058 3.639 3.799 46.47 ± 0.91
cairo-native (standalone AOT with -march=native) 0.080 ± 0.001 0.080 0.084 1.00

Benchmark for program linear_search

Open benchmarks
Command Mean [s] Min [s] Max [s] Relative
Cairo-vm (Rust, Cairo 1) 5.816 ± 0.023 5.778 5.843 2875.25 ± 61.51
cairo-native (embedded AOT) 3.842 ± 0.018 3.808 3.868 1899.45 ± 40.88
cairo-native (embedded JIT using LLVM's ORC Engine) 3.782 ± 0.046 3.711 3.848 1869.75 ± 45.38
cairo-native (standalone AOT with -march=native) 0.002 ± 0.000 0.002 0.002 1.00

Benchmark for program logistic_map

Open benchmarks
Command Mean [s] Min [s] Max [s] Relative
Cairo-vm (Rust, Cairo 1) 5.761 ± 0.032 5.690 5.799 23.75 ± 0.14
cairo-native (embedded AOT) 4.023 ± 0.034 3.976 4.090 16.58 ± 0.14
cairo-native (embedded JIT using LLVM's ORC Engine) 3.928 ± 0.027 3.886 3.964 16.19 ± 0.11
cairo-native (standalone AOT with -march=native) 0.243 ± 0.000 0.242 0.244 1.00

@azteca1998
Copy link
Collaborator

The '\0' is there because C strings work that way. Please do not remove it.

The condition length > version.len() should ensure that target has enough space for the version, including the final \0 byte.

The only thing that needs to be changed is the length by version.len(), which you already did. Everything else is not necessary. You can move the slice::from_raw_parts until after the check, but it shouldn't affect anything because we're not accessing it until we've checked we can do so.

@FrancoGiachetta
Copy link
Contributor Author

FrancoGiachetta commented Jan 7, 2025

Oh, you are right. I removed the '\0' in the previous approach, which was using a buffer with the same length as version from the beginning and so inserting '\0' would overwrite the last byte. I'll change it.

@edg-l edg-l added this pull request to the merge queue Jan 8, 2025
Merged via the queue into main with commit a561062 Jan 8, 2025
32 checks passed
@edg-l edg-l deleted the fix-runtime-version-check branch January 8, 2025 14:59
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.

5 participants