Skip to content

performance(sierra-to-casm): Changed felt252 deseralization to be based on an iterator.#9465

Closed
orizi wants to merge 1 commit intoorizi/01-11-performance_sierra-to-casm_made_referenceexpression_applyapchange_more_inplacefrom
orizi/01-12-performance_sierra-to-casm_changed_felt252_deseralization_to_be_based_on_an_iterator
Closed

performance(sierra-to-casm): Changed felt252 deseralization to be based on an iterator.#9465
orizi wants to merge 1 commit intoorizi/01-11-performance_sierra-to-casm_made_referenceexpression_applyapchange_more_inplacefrom
orizi/01-12-performance_sierra-to-casm_changed_felt252_deseralization_to_be_based_on_an_iterator

Conversation

@orizi
Copy link
Collaborator

@orizi orizi commented Jan 13, 2026

Summary

Refactored the Felt252Serde trait to use iterators instead of slices for deserialization. This changes the trait's deserialize method signature from returning a tuple of (Self, &[BigUintAsHex]) to just returning Self and taking a mutable iterator of &BigUint references. Also updated the decompress function to return a vector of &BigUint instead of mutating an output vector.

Type of change

  • Performance improvement

Why is this change needed?

The current implementation of deserialization passes slices around and returns the remaining slice after each deserialization step. This approach is less efficient and more error-prone than using iterators. The iterator-based approach simplifies the code and makes it more maintainable while potentially improving performance.

What was the behavior or documentation before?

The Felt252Serde trait's deserialize method took a slice of BigUintAsHex and returned a tuple containing the deserialized value and the remaining slice. The decompress function took an output vector parameter that it would mutate with the decompressed values.

What is the behavior or documentation after?

The Felt252Serde trait's deserialize method now takes a mutable iterator of &BigUint references and returns just the deserialized value. The decompress function now returns a vector of &BigUint references instead of mutating an output parameter.

Additional context

A TODO comment was added to validate that changing the version_id_from_felt252s function is acceptable and to make it iterator-based as well in the future.

@reviewable-StarkWare
Copy link

This change is Reviewable

Copy link
Collaborator Author

orizi commented Jan 13, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

…ed on an iterator.

Vastly reducing the number of BigInt clones performed.

SIERRA_UPDATE_PATCH_CHANGE_TAG=Internal change only.
@orizi orizi force-pushed the orizi/01-12-performance_sierra-to-casm_changed_felt252_deseralization_to_be_based_on_an_iterator branch from 5bdde35 to c943c75 Compare January 13, 2026 17:10
@orizi orizi force-pushed the orizi/01-11-performance_sierra-to-casm_made_referenceexpression_applyapchange_more_inplace branch from e397122 to 86e315e Compare January 13, 2026 17:10
@orizi orizi deleted the branch orizi/01-11-performance_sierra-to-casm_made_referenceexpression_applyapchange_more_inplace January 13, 2026 17:34
@orizi orizi closed this Jan 13, 2026
@orizi orizi deleted the orizi/01-12-performance_sierra-to-casm_changed_felt252_deseralization_to_be_based_on_an_iterator branch January 14, 2026 16:52
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