Skip to content

performance(sierra-gas): Simplified GasInfo::combine implementation.#9552

Merged
orizi merged 1 commit intomainfrom
orizi/01-28-performance_sierra-gas_simplified_gasinfo_combine_implementation
Jan 28, 2026
Merged

performance(sierra-gas): Simplified GasInfo::combine implementation.#9552
orizi merged 1 commit intomainfrom
orizi/01-28-performance_sierra-gas_simplified_gasinfo_combine_implementation

Conversation

@orizi
Copy link
Collaborator

@orizi orizi commented Jan 28, 2026

Summary

Refactored the combine method in GasInfo to use more efficient entry-based operations instead of creating new collections. The new implementation directly updates the existing variable_values and function_costs maps by iterating through the entries of the other GasInfo instance and adding values to the corresponding entries or inserting new ones when needed.


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 of combine was inefficient as it created new collections by first collecting unique keys from both maps, then creating new entries with combined values. This approach involved unnecessary allocations and computations. The new implementation directly updates the existing maps, reducing memory allocations and improving performance.


What was the behavior or documentation before?

The previous implementation created new collections by collecting unique keys, swapping out values, and building new maps from scratch, which was less efficient.


What is the behavior or documentation after?

The new implementation maintains the same functionality but uses the Entry API to directly update the existing maps in-place, reducing allocations and improving performance. It also adds a descriptive comment about the method's purpose.


Additional context

This change is part of ongoing performance optimizations in the Sierra gas calculation system. The functionality remains identical, but the implementation is more efficient.

@reviewable-StarkWare
Copy link

This change is Reviewable

@orizi orizi requested a review from eytan-starkware January 28, 2026 11:53
Copy link
Collaborator Author

orizi commented Jan 28, 2026

@orizi orizi marked this pull request as ready for review January 28, 2026 11:53
@orizi orizi force-pushed the orizi/01-28-performance_sierra-gas_simplified_gasinfo_combine_implementation branch from 42f5d05 to e04df7d Compare January 28, 2026 12:11
SIERRA_UPDATE_PATCH_CHANGE_TAG=No interface change.
@orizi orizi changed the base branch from orizi/01-28-refactor_sierra_made_all_sierra_functions_expect_statenentidx_without_ to graphite-base/9552 January 28, 2026 12:27
@orizi orizi force-pushed the orizi/01-28-performance_sierra-gas_simplified_gasinfo_combine_implementation branch from e04df7d to f8e8e40 Compare January 28, 2026 12:28
@orizi orizi force-pushed the graphite-base/9552 branch from c9e404d to 00a0d97 Compare January 28, 2026 12:28
@orizi orizi changed the base branch from graphite-base/9552 to main January 28, 2026 12:28
@orizi orizi enabled auto-merge January 28, 2026 12:28
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 @orizi).

@orizi orizi added this pull request to the merge queue Jan 28, 2026
Merged via the queue into main with commit ca54a85 Jan 28, 2026
108 checks passed
@orizi orizi deleted the orizi/01-28-performance_sierra-gas_simplified_gasinfo_combine_implementation branch January 28, 2026 15:33
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