perf(array): always double capacity on realloc - #1659
Merged
Conversation
Previously growth was capped at +1024 elements once capacity reached 512, making large arrays grow linearly (O(n^2) total copying). Now capacity always doubles (minimum 8). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Benchmarking resultsBenchmark for program
|
| Command | Mean [s] | Min [s] | Max [s] | Relative |
|---|---|---|---|---|
Cairo-vm (Rust, Cairo 1) |
10.472 ± 0.041 | 10.398 | 10.530 | 5.72 ± 0.06 |
cairo-native (embedded AOT) |
1.830 ± 0.017 | 1.804 | 1.865 | 1.00 |
cairo-native (embedded JIT using LLVM's ORC Engine) |
1.838 ± 0.012 | 1.818 | 1.856 | 1.00 ± 0.01 |
Benchmark for program dict_snapshot
Open benchmarks
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
Cairo-vm (Rust, Cairo 1) |
528.1 ± 4.5 | 521.7 | 536.1 | 1.00 |
cairo-native (embedded AOT) |
1634.2 ± 8.7 | 1621.1 | 1649.5 | 3.09 ± 0.03 |
cairo-native (embedded JIT using LLVM's ORC Engine) |
1657.8 ± 9.2 | 1648.8 | 1678.8 | 3.14 ± 0.03 |
Benchmark for program factorial_2M
Open benchmarks
| Command | Mean [s] | Min [s] | Max [s] | Relative |
|---|---|---|---|---|
Cairo-vm (Rust, Cairo 1) |
4.656 ± 0.018 | 4.635 | 4.686 | 2.75 ± 0.03 |
cairo-native (embedded AOT) |
1.693 ± 0.014 | 1.672 | 1.723 | 1.00 |
cairo-native (embedded JIT using LLVM's ORC Engine) |
1.734 ± 0.019 | 1.709 | 1.762 | 1.02 ± 0.01 |
Benchmark for program fib_2M
Open benchmarks
| Command | Mean [s] | Min [s] | Max [s] | Relative |
|---|---|---|---|---|
Cairo-vm (Rust, Cairo 1) |
4.570 ± 0.028 | 4.535 | 4.618 | 2.79 ± 0.04 |
cairo-native (embedded AOT) |
1.635 ± 0.019 | 1.618 | 1.669 | 1.00 |
cairo-native (embedded JIT using LLVM's ORC Engine) |
1.665 ± 0.020 | 1.630 | 1.696 | 1.02 ± 0.02 |
Benchmark for program linear_search
Open benchmarks
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
Cairo-vm (Rust, Cairo 1) |
571.0 ± 10.2 | 558.4 | 593.8 | 1.00 |
cairo-native (embedded AOT) |
1658.2 ± 17.9 | 1638.4 | 1686.1 | 2.90 ± 0.06 |
cairo-native (embedded JIT using LLVM's ORC Engine) |
1685.9 ± 12.9 | 1671.7 | 1707.7 | 2.95 ± 0.06 |
Benchmark for program logistic_map
Open benchmarks
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
Cairo-vm (Rust, Cairo 1) |
483.7 ± 5.0 | 476.7 | 492.1 | 1.00 |
cairo-native (embedded AOT) |
1637.1 ± 9.5 | 1620.9 | 1649.3 | 3.38 ± 0.04 |
cairo-native (embedded JIT using LLVM's ORC Engine) |
1665.3 ± 14.1 | 1645.6 | 1692.5 | 3.44 ± 0.05 |
Benchmark results Main vs HEAD.Base
Head
Base
Head
Base
Head
Base
Head
Base
Head
Base
Head
|
orizi
approved these changes
Aug 30, 2026
orizi
left a comment
Collaborator
There was a problem hiding this comment.
@orizi reviewed 1 file and all commit messages, and made 1 comment.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on TomerStarkware).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change is