Skip to content

Conversation

@orizi
Copy link
Collaborator

@orizi orizi commented Jan 17, 2026

Summary

Optimized the stack size calculation in the ProgramAnnotations implementation by using a more efficient approach. The previous implementation used an UnorderedHashSet to track available stack indices, while the new implementation uses a boolean vector to mark available indices, which should be more performant. Additionally, added a special case to handle when the new stack size is zero.


Type of change

Please check one:

  • Bug fix (fixes incorrect behavior)
  • New feature
  • Performance improvement
  • Documentation change with concrete technical impact
  • Style, wording, formatting, or typo-only change

Why is this change needed?

The previous implementation for calculating stack size in the Sierra-to-CASM compiler used an UnorderedHashSet to track available stack indices, which is less efficient than using a boolean vector. This change improves performance by replacing the hash set with a vector-based approach that directly marks which indices are available.


What was the behavior or documentation before?

The code used an UnorderedHashSet to collect all available stack indices and then searched for the first missing index to determine the new stack size.


What is the behavior or documentation after?

The code now uses a boolean vector to mark available stack indices, which is more efficient. It also adds a special case to handle when the new stack size is zero, avoiding unnecessary calculations.

@reviewable-StarkWare
Copy link

This change is Reviewable

@orizi orizi marked this pull request as ready for review January 17, 2026 08:11
@orizi orizi changed the base branch from orizi/01-15-performance_sierra-to-casm_using_builder_with_capacity_for_instructions_and_relocations to graphite-base/9491 January 19, 2026 06:38
Copy link
Contributor

@eytan-starkware eytan-starkware left a comment

Choose a reason for hiding this comment

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

:lgtm:

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

SIERRA_UPDATE_PATCH_CHANGE_TAG=No interface changes.
@orizi orizi force-pushed the graphite-base/9491 branch from b056dc0 to 6a874aa Compare January 20, 2026 10:03
@orizi orizi force-pushed the orizi/01-15-performance_sierra-to-casm_improved_stack-tracking_algorithm branch from d54e998 to 78490a5 Compare January 20, 2026 10:03
@orizi orizi changed the base branch from graphite-base/9491 to main January 20, 2026 10:03
@orizi orizi added this pull request to the merge queue Jan 20, 2026
Merged via the queue into main with commit 3ac037b Jan 20, 2026
108 checks passed
@orizi orizi deleted the orizi/01-15-performance_sierra-to-casm_improved_stack-tracking_algorithm branch January 20, 2026 12:51
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.

4 participants