Skip to content
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

chore(sequencing): replace BTreeMap with HashMap in StreamHandler #2517

Merged
merged 1 commit into from
Dec 10, 2024

Conversation

guy-starkware
Copy link
Contributor

@guy-starkware guy-starkware commented Dec 8, 2024

I've wanted to remove the BTreeMap from StreamHandler for a while.
It functions the same as HashMap but has the ordered keys feature, which we no longer use.

It seems simpler to just work with one kind of map.

@reviewable-StarkWare
Copy link

This change is Reviewable

@guy-starkware guy-starkware marked this pull request as ready for review December 8, 2024 09:57
@guy-starkware guy-starkware force-pushed the 12-08-chore_sequencer_remove_proposalchunk_type branch from 78dd7ea to bb57c46 Compare December 8, 2024 10:09
@guy-starkware guy-starkware force-pushed the guyn/streams/hash_map_type branch from 29a7123 to 60d4672 Compare December 8, 2024 10:09
Copy link

codecov bot commented Dec 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 13.22%. Comparing base (e3165c4) to head (e759892).
Report is 814 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #2517       +/-   ##
===========================================
- Coverage   40.10%   13.22%   -26.89%     
===========================================
  Files          26       63       +37     
  Lines        1895     7744     +5849     
  Branches     1895     7744     +5849     
===========================================
+ Hits          760     1024      +264     
- Misses       1100     6683     +5583     
- Partials       35       37        +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@asmaastarkware asmaastarkware left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 2 files at r1, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @guy-starkware and @matan-starkware)


crates/sequencing/papyrus_consensus/src/stream_handler_test.rs line 38 at r1 (raw file):

    // Check if two vectors are the same, regardless of ordering
    fn do_vecs_match_unordered<T: PartialEq>(a: &[T], b: &[T]) -> bool

it also ignores duplicates, is this what u want?

@guy-starkware guy-starkware force-pushed the 12-08-chore_sequencer_remove_proposalchunk_type branch from 8682fd1 to 7bc63e0 Compare December 10, 2024 07:31
@guy-starkware guy-starkware force-pushed the guyn/streams/hash_map_type branch 2 times, most recently from ea76fac to 379fbbb Compare December 10, 2024 07:41
Copy link
Contributor Author

@guy-starkware guy-starkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: 1 of 2 files reviewed, 1 unresolved discussion (waiting on @asmaastarkware and @matan-starkware)


crates/sequencing/papyrus_consensus/src/stream_handler_test.rs line 38 at r1 (raw file):

Previously, asmaastarkware (asmaa-starkware) wrote…

it also ignores duplicates, is this what u want?

You are right. This probably doesn't matter in these test cases, but I will use a different comparison (I'm just going to order the vectors before checking the values.

@guy-starkware guy-starkware force-pushed the 12-08-chore_sequencer_remove_proposalchunk_type branch from 7bc63e0 to f2ad96b Compare December 10, 2024 08:11
@guy-starkware guy-starkware force-pushed the guyn/streams/hash_map_type branch from 379fbbb to 0c88ba4 Compare December 10, 2024 08:11
@guy-starkware guy-starkware force-pushed the 12-08-chore_sequencer_remove_proposalchunk_type branch from f2ad96b to a5d57e5 Compare December 10, 2024 08:24
@guy-starkware guy-starkware force-pushed the guyn/streams/hash_map_type branch from 0c88ba4 to 3e48a5f Compare December 10, 2024 08:24
@guy-starkware guy-starkware force-pushed the 12-08-chore_sequencer_remove_proposalchunk_type branch from a5d57e5 to 2f802e2 Compare December 10, 2024 08:25
@guy-starkware guy-starkware force-pushed the guyn/streams/hash_map_type branch from 3e48a5f to c9b269b Compare December 10, 2024 08:25
Copy link
Contributor

@asmaastarkware asmaastarkware left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r2, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @guy-starkware and @matan-starkware)


crates/sequencing/papyrus_consensus/src/stream_handler_test.rs line 47 at r2 (raw file):

        b.sort();
        let matching = a.iter().zip(b.iter()).filter(|&(a, b)| a == b).count();
        matching == a.len() && matching == b.len()

Check lengths first to avoid unnecessary sorting

Suggestion:

        if a.len() != b.len() {
            return false;
        }
        let mut a = a.clone();
        a.sort();
        let mut b = b.clone();
        b.sort();
        a == b

Copy link
Contributor Author

@guy-starkware guy-starkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @asmaastarkware and @matan-starkware)


crates/sequencing/papyrus_consensus/src/stream_handler_test.rs line 47 at r2 (raw file):

Previously, asmaastarkware (asmaa-starkware) wrote…

Check lengths first to avoid unnecessary sorting

For some reason I didn't know that a==b works. I think we can get rid of the length check altogether. As this is a test (on few elements) I don't see a reason to optimize it by checking lengths at all...

Thanks!

@guy-starkware guy-starkware force-pushed the guyn/streams/hash_map_type branch from c9b269b to 92b40d1 Compare December 10, 2024 09:53
Copy link
Contributor

@asmaastarkware asmaastarkware left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 1 of 1 files at r3, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @matan-starkware)

@guy-starkware guy-starkware force-pushed the 12-08-chore_sequencer_remove_proposalchunk_type branch from 2f802e2 to 307e662 Compare December 10, 2024 10:32
@guy-starkware guy-starkware force-pushed the guyn/streams/hash_map_type branch from 92b40d1 to 389e22b Compare December 10, 2024 10:33
Copy link
Contributor

@matan-starkware matan-starkware left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 2 files at r1, 1 of 1 files at r3, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @guy-starkware)

Copy link
Contributor Author

guy-starkware commented Dec 10, 2024

Merge activity

  • Dec 10, 9:07 AM EST: A user started a stack merge that includes this pull request via Graphite.
  • Dec 10, 9:09 AM EST: Graphite rebased this pull request as part of a merge.
  • Dec 10, 9:36 AM EST: Graphite couldn't merge this PR because it was not satisfying all requirements (Failed CI: 'merge-gatekeeper').

@guy-starkware guy-starkware changed the base branch from 12-08-chore_sequencer_remove_proposalchunk_type to graphite-base/2517 December 10, 2024 14:08
@guy-starkware guy-starkware changed the base branch from graphite-base/2517 to main December 10, 2024 14:08
@guy-starkware guy-starkware force-pushed the guyn/streams/hash_map_type branch from 389e22b to e759892 Compare December 10, 2024 14:08
@guy-starkware guy-starkware merged commit 70e9d8f into main Dec 10, 2024
17 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Dec 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants