-
Notifications
You must be signed in to change notification settings - Fork 738
Improve sierra debug info serde. #9525
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
eytan-starkware
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eytan-starkware reviewed 1 file and all commit messages, and made 3 comments.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @orizi and @TomerStarkware).
crates/cairo-lang-sierra/src/debug_info.rs line 208 at r1 (raw file):
serializer: S, ) -> Result<S::Ok, S::Error> { let mut seq = serializer.serialize_seq(Some(m.len()))?;
Why not serializer.collect_seq(...)?
crates/cairo-lang-sierra/src/debug_info.rs line 228 at r1 (raw file):
type Value = OrderedHashMap<Id, SmolStr>; fn expecting(&self, formatter: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
Essentially reimplementing indexmap: https://docs.rs/indexmap/latest/src/indexmap/map/serde_seq.rs.html#1-138
orizi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@orizi made 2 comments.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @eytan-starkware and @TomerStarkware).
crates/cairo-lang-sierra/src/debug_info.rs line 208 at r1 (raw file):
Previously, eytan-starkware wrote…
Why not
serializer.collect_seq(...)?
Done.
crates/cairo-lang-sierra/src/debug_info.rs line 228 at r1 (raw file):
Previously, eytan-starkware wrote…
Essentially reimplementing indexmap: https://docs.rs/indexmap/latest/src/indexmap/map/serde_seq.rs.html#1-138
cool.
Done.
TomerStarkware
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TomerStarkware reviewed all commit messages and made 1 comment.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @eytan-starkware).
eytan-starkware
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eytan-starkware made 1 comment.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @orizi).
crates/cairo-lang-sierra/src/debug_info.rs line 208 at r1 (raw file):
Previously, orizi wrote…
Done.
not seeing it
ed9d971 to
19723f9
Compare
8573a25 to
cb68427
Compare
eytan-starkware
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eytan-starkware reviewed all commit messages, made 1 comment, and resolved 1 discussion.
Reviewable status: 0 of 1 files reviewed, 1 unresolved discussion (waiting on @orizi).
crates/cairo-lang-sierra/src/debug_info.rs line 228 at r1 (raw file):
Previously, orizi wrote…
cool.
Done.
No change here as well
orizi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@orizi made 2 comments.
Reviewable status: 0 of 1 files reviewed, 1 unresolved discussion (waiting on @eytan-starkware).
crates/cairo-lang-sierra/src/debug_info.rs line 208 at r1 (raw file):
Previously, eytan-starkware wrote…
not seeing it
got the wrong PR - done now.
crates/cairo-lang-sierra/src/debug_info.rs line 228 at r1 (raw file):
Previously, eytan-starkware wrote…
No change here as well
same - yeah - it is essentially the same thing.
eytan-starkware
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eytan-starkware made 1 comment.
Reviewable status: 0 of 1 files reviewed, 1 unresolved discussion (waiting on @orizi).
crates/cairo-lang-sierra/src/debug_info.rs line 228 at r1 (raw file):
Previously, orizi wrote…
same - yeah - it is essentially the same thing.
And we are already using the indexmap serialization in other places. Why reimplement? We have 3 ordered hash map de/serialize
orizi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@orizi made 1 comment.
Reviewable status: 0 of 1 files reviewed, 1 unresolved discussion (waiting on @eytan-starkware).
crates/cairo-lang-sierra/src/debug_info.rs line 228 at r1 (raw file):
Previously, eytan-starkware wrote…
And we are already using the indexmap serialization in other places. Why reimplement? We have 3 ordered hash map de/serialize
the id conversion is required. (Id::new(k))
eytan-starkware
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eytan-starkware reviewed 1 file, made 1 comment, and resolved 1 discussion.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @orizi).
SIERRA_UPDATE_NO_CHANGE_TAG=No interface change.
cb68427 to
5681777
Compare
19723f9 to
58308ae
Compare

Summary
Refactored the serialization and deserialization of
OrderedHashMapin the debug info module to use a more efficient approach. Instead of collecting items into a temporary vector, the implementation now directly serializes elements into a sequence. For deserialization, introduced a customVisitorimplementation that properly handles sequence access and constructs the map directly.Type of change
Please check one:
Why is this change needed?
The previous implementation of serialization and deserialization for
OrderedHashMapwas inefficient as it created intermediate collections. This change improves performance by eliminating the need for temporary vectors during serialization and deserialization processes.What was the behavior or documentation before?
Previously, the code would collect all map entries into a temporary vector during serialization, and similarly deserialize into a vector before converting back to an
OrderedHashMap.What is the behavior or documentation after?
Now the implementation directly serializes map entries into a sequence without the intermediate collection. For deserialization, a custom
Visitorimplementation properly handles sequence access and constructs the map directly with appropriate size hints when available.Additional context
This change follows serialization best practices by using the visitor pattern for deserialization and direct sequence serialization, which should be more memory efficient for large maps.