Skip to content

removed dup/drop bindings#1617

Merged
TomerStarkware merged 1 commit into
mainfrom
tomer/remove_dup_bindingins
May 19, 2026
Merged

removed dup/drop bindings#1617
TomerStarkware merged 1 commit into
mainfrom
tomer/remove_dup_bindingins

Conversation

@TomerStarkware

@TomerStarkware TomerStarkware commented May 18, 2026

Copy link
Copy Markdown
Collaborator

Remove dup/drop overrides; rely on arena ownership

Closes #NA

Now that all heap-allocated types (Box<T>, Nullable<T>, Array<T>, dicts, and the structs/enums containing them) live in the per-invocation
arena, deep clones and recursive drops are no longer necessary. Memory is reclaimed when the arena is destroyed at invocation end, and pointer-typed
values can be shared freely between branches because no libfunc mutates through an input box pointer.

This PR removes the DupOverridesMeta / DropOverridesMeta metadata and all associated code:

  • Deletes src/metadata/drop_overrides.rs and src/metadata/dup_overrides.rs (~420 lines).
  • dup libfunc becomes a bitwise copy — return the same SSA value twice.
  • drop libfunc becomes a no-op.
  • Per-type dup/drop builders are removed from array, box, enum, nullable, snapshot, and struct (~1300 lines).
  • array_pop / array_get no longer deep-copy popped elements; they return GEP'd pointers into the source arena slot.
  • array_slice, array_len, circuit_eval, get_circuit_output, sha256_process_block, and debug::print drop their now-redundant drop
    invocations on consumed inputs.
  • struct_boxed_deconstruct / enum_boxed_match return field/payload pointers via GEP instead of unboxing and re-boxing each member.

Net diff: ~+300/-2100 in src/.

Introduces Breaking Changes?

No. The runtime ABI and libfunc semantics are unchanged — dup still returns two values, drop still consumes one, and consumed boxed values still
cannot be reused by the Sierra program. Only the MLIR codegen behind these libfuncs changes.


This change is Reviewable

@TomerStarkware
TomerStarkware requested a review from orizi May 18, 2026 21:20

@orizi orizi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

:lgtm:

@orizi reviewed 20 files and all commit messages, and made 2 comments.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on TomerStarkware).


src/libfuncs/const.rs line 77 at r1 (raw file):

    let inner_layout = const_ty.layout(registry)?;

    // TODO: For struct/enum const types we could emit the constant directly into the arena slot

can't this point to some constant memory?
i'm assuming llvm has some such feature.

@TomerStarkware
TomerStarkware force-pushed the tomer/remove_dup_bindingins branch from 4a0b31a to 27d6b14 Compare May 19, 2026 08:05

@orizi orizi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@orizi reviewed 22 files and all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on TomerStarkware).

@TomerStarkware
TomerStarkware force-pushed the tomer/arena_dict branch 2 times, most recently from af42e6f to f97c196 Compare May 19, 2026 09:19
Base automatically changed from tomer/arena_dict to main May 19, 2026 10:43
@TomerStarkware
TomerStarkware force-pushed the tomer/remove_dup_bindingins branch 2 times, most recently from 19dd67b to d162d7c Compare May 19, 2026 10:47

@TomerStarkware TomerStarkware left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@TomerStarkware made 1 comment.
Reviewable status: 23 of 39 files reviewed, 1 unresolved discussion (waiting on orizi).


src/libfuncs/const.rs line 77 at r1 (raw file):

Previously, orizi wrote…

can't this point to some constant memory?
i'm assuming llvm has some such feature.

Done.

@orizi orizi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

:lgtm:

@orizi reviewed 17 files and all commit messages, made 1 comment, and resolved 1 discussion.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on TomerStarkware).

@TomerStarkware
TomerStarkware force-pushed the tomer/remove_dup_bindingins branch from d162d7c to 9641a97 Compare May 19, 2026 12:17
@TomerStarkware
TomerStarkware force-pushed the tomer/remove_dup_bindingins branch from 9641a97 to aa65112 Compare May 19, 2026 12:27
@github-actions

Copy link
Copy Markdown

Benchmark results Main vs HEAD.

Base

Command Mean [s] Min [s] Max [s] Relative
base dict_insert.cairo (JIT) 1.904 ± 0.023 1.869 1.943 1.03 ± 0.02
base dict_insert.cairo (AOT) 1.852 ± 0.023 1.821 1.887 1.00

Head

Command Mean [s] Min [s] Max [s] Relative
head dict_insert.cairo (JIT) 1.856 ± 0.020 1.816 1.888 1.02 ± 0.02
head dict_insert.cairo (AOT) 1.829 ± 0.019 1.805 1.856 1.00

Base

Command Mean [s] Min [s] Max [s] Relative
base dict_snapshot.cairo (JIT) 1.758 ± 0.020 1.724 1.780 1.06 ± 0.01
base dict_snapshot.cairo (AOT) 1.652 ± 0.012 1.638 1.677 1.00

Head

Command Mean [s] Min [s] Max [s] Relative
head dict_snapshot.cairo (JIT) 1.666 ± 0.013 1.647 1.686 1.01 ± 0.01
head dict_snapshot.cairo (AOT) 1.644 ± 0.013 1.628 1.660 1.00

Base

Command Mean [s] Min [s] Max [s] Relative
base factorial_2M.cairo (JIT) 2.195 ± 0.018 2.175 2.227 1.02 ± 0.01
base factorial_2M.cairo (AOT) 2.144 ± 0.007 2.132 2.154 1.00

Head

Command Mean [s] Min [s] Max [s] Relative
head factorial_2M.cairo (JIT) 2.157 ± 0.020 2.121 2.191 1.00 ± 0.01
head factorial_2M.cairo (AOT) 2.152 ± 0.018 2.124 2.183 1.00

Base

Command Mean [s] Min [s] Max [s] Relative
base fib_2M.cairo (JIT) 1.710 ± 0.009 1.700 1.721 1.03 ± 0.01
base fib_2M.cairo (AOT) 1.655 ± 0.009 1.642 1.667 1.00

Head

Command Mean [s] Min [s] Max [s] Relative
head fib_2M.cairo (JIT) 1.676 ± 0.014 1.657 1.700 1.01 ± 0.01
head fib_2M.cairo (AOT) 1.656 ± 0.016 1.632 1.680 1.00

Base

Command Mean [s] Min [s] Max [s] Relative
base linear_search.cairo (JIT) 1.794 ± 0.011 1.774 1.813 1.06 ± 0.02
base linear_search.cairo (AOT) 1.699 ± 0.024 1.671 1.752 1.00

Head

Command Mean [s] Min [s] Max [s] Relative
head linear_search.cairo (JIT) 1.714 ± 0.018 1.691 1.747 1.00
head linear_search.cairo (AOT) 1.724 ± 0.022 1.687 1.756 1.01 ± 0.02

Base

Command Mean [s] Min [s] Max [s] Relative
base logistic_map.cairo (JIT) 2.009 ± 0.017 1.983 2.038 1.10 ± 0.01
base logistic_map.cairo (AOT) 1.825 ± 0.012 1.805 1.840 1.00

Head

Command Mean [s] Min [s] Max [s] Relative
head logistic_map.cairo (JIT) 2.008 ± 0.035 1.956 2.080 1.09 ± 0.02
head logistic_map.cairo (AOT) 1.845 ± 0.022 1.821 1.889 1.00

@github-actions

Copy link
Copy Markdown

Benchmarking results

Benchmark for program dict_insert

Open benchmarks
Command Mean [s] Min [s] Max [s] Relative
Cairo-vm (Rust, Cairo 1) 11.505 ± 0.096 11.381 11.687 6.07 ± 0.10
cairo-native (embedded AOT) 1.914 ± 0.032 1.863 1.966 1.01 ± 0.02
cairo-native (embedded JIT using LLVM's ORC Engine) 1.896 ± 0.027 1.861 1.938 1.00

Benchmark for program dict_snapshot

Open benchmarks
Command Mean [ms] Min [ms] Max [ms] Relative
Cairo-vm (Rust, Cairo 1) 557.9 ± 6.0 552.0 570.2 1.00
cairo-native (embedded AOT) 1734.7 ± 28.4 1677.3 1775.0 3.11 ± 0.06
cairo-native (embedded JIT using LLVM's ORC Engine) 1762.7 ± 29.1 1715.8 1802.7 3.16 ± 0.06

Benchmark for program factorial_2M

Open benchmarks
Command Mean [s] Min [s] Max [s] Relative
Cairo-vm (Rust, Cairo 1) 4.992 ± 0.021 4.964 5.039 2.25 ± 0.03
cairo-native (embedded AOT) 2.226 ± 0.026 2.176 2.267 1.00 ± 0.02
cairo-native (embedded JIT using LLVM's ORC Engine) 2.216 ± 0.025 2.181 2.266 1.00

Benchmark for program fib_2M

Open benchmarks
Command Mean [s] Min [s] Max [s] Relative
Cairo-vm (Rust, Cairo 1) 4.914 ± 0.023 4.887 4.954 2.82 ± 0.05
cairo-native (embedded AOT) 1.742 ± 0.031 1.706 1.795 1.00
cairo-native (embedded JIT using LLVM's ORC Engine) 1.754 ± 0.026 1.702 1.794 1.01 ± 0.02

Benchmark for program linear_search

Open benchmarks
Command Mean [ms] Min [ms] Max [ms] Relative
Cairo-vm (Rust, Cairo 1) 612.4 ± 12.5 593.4 635.3 1.00
cairo-native (embedded AOT) 1757.3 ± 36.3 1712.2 1805.2 2.87 ± 0.08
cairo-native (embedded JIT using LLVM's ORC Engine) 1784.9 ± 23.1 1754.9 1830.9 2.91 ± 0.07

Benchmark for program logistic_map

Open benchmarks
Command Mean [ms] Min [ms] Max [ms] Relative
Cairo-vm (Rust, Cairo 1) 503.9 ± 13.1 494.0 539.6 1.00
cairo-native (embedded AOT) 1864.3 ± 17.9 1844.9 1895.6 3.70 ± 0.10
cairo-native (embedded JIT using LLVM's ORC Engine) 1987.9 ± 21.1 1963.2 2019.2 3.95 ± 0.11

@orizi orizi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@orizi reviewed 1 file and all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on TomerStarkware).

@TomerStarkware
TomerStarkware added this pull request to the merge queue May 19, 2026
Merged via the queue into main with commit 2463ca0 May 19, 2026
26 checks passed
@TomerStarkware
TomerStarkware deleted the tomer/remove_dup_bindingins branch May 19, 2026 14:01
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.

2 participants