Skip to content

performance(sierra-to-casm): Better moving of annotations.#9447

Merged
orizi merged 1 commit intomainfrom
orizi/01-11-performance_sierra-to-casm_better_moving_of_annotations
Jan 13, 2026
Merged

performance(sierra-to-casm): Better moving of annotations.#9447
orizi merged 1 commit intomainfrom
orizi/01-11-performance_sierra-to-casm_better_moving_of_annotations

Conversation

@orizi
Copy link
Collaborator

@orizi orizi commented Jan 11, 2026

Summary

Refactored the take_annotations method in ProgramAnnotations to simplify the logic for handling statement annotations. Instead of creating a temporary replacement and then swapping values, the method now takes ownership of the annotations entry directly, clones it if needed for backward jumps, and returns the modified entry.


Type of change

Please check one:

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

Why is this change needed?

The previous implementation of take_annotations was unnecessarily complex, using multiple memory operations (replace, take) and creating temporary objects. This change simplifies the code flow and reduces memory operations by taking ownership of the annotation entry directly.


What was the behavior or documentation before?

The method would retrieve a mutable reference to the annotations, create a temporary replacement, and use std::mem::replace and std::mem::take to swap values around.


What is the behavior or documentation after?

The method now uses take() to get ownership of the annotations directly, clones them only when necessary (for backward jumps), and returns the modified entry without unnecessary memory operations.


Additional context

This change maintains the same functionality while making the code more straightforward and potentially more efficient by reducing memory operations and temporary object creation.

@reviewable-StarkWare
Copy link

This change is Reviewable

Copy link
Collaborator Author

orizi commented Jan 11, 2026

Copy link
Collaborator

@TomerStarkware TomerStarkware left a comment

Choose a reason for hiding this comment

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

:lgtm:

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

@orizi orizi force-pushed the orizi/01-11-refactoring_sierra-to-casm_removed_specific_instruction-to-offset_map branch from 7a719e0 to 63d2f2c Compare January 13, 2026 13:52
@orizi orizi force-pushed the orizi/01-11-performance_sierra-to-casm_better_moving_of_annotations branch from 5ee68e9 to 0277b49 Compare January 13, 2026 13:52
@orizi orizi changed the base branch from orizi/01-11-refactoring_sierra-to-casm_removed_specific_instruction-to-offset_map to graphite-base/9447 January 13, 2026 14:53
Allocating less when taking old annotations.

SIERRA_UPDATE_MINOR_CHANGE_TAG=No interface change.
@orizi orizi force-pushed the graphite-base/9447 branch from 63d2f2c to d7e77ed Compare January 13, 2026 15:47
@orizi orizi force-pushed the orizi/01-11-performance_sierra-to-casm_better_moving_of_annotations branch from 0277b49 to 836fae2 Compare January 13, 2026 15:47
@orizi orizi changed the base branch from graphite-base/9447 to main January 13, 2026 15:48
@orizi orizi added this pull request to the merge queue Jan 13, 2026
Merged via the queue into main with commit 35a6fef Jan 13, 2026
108 checks passed
@orizi orizi deleted the orizi/01-11-performance_sierra-to-casm_better_moving_of_annotations branch January 13, 2026 17:19
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.

3 participants