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(network): stress test utils #1995

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

eitanm-starkware
Copy link
Contributor

No description provided.

@reviewable-StarkWare
Copy link

This change is Reviewable

Copy link

codecov bot commented Nov 12, 2024

Codecov Report

Attention: Patch coverage is 0% with 5 lines in your changes missing coverage. Please review.

Project coverage is 34.65%. Comparing base (e3165c4) to head (79248c0).
Report is 365 commits behind head on main.

Files with missing lines Patch % Lines
..._network/src/bin/network_stress_test/converters.rs 0.00% 4 Missing ⚠️
crates/papyrus_network/src/lib.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1995      +/-   ##
==========================================
- Coverage   40.10%   34.65%   -5.45%     
==========================================
  Files          26       56      +30     
  Lines        1895     4931    +3036     
  Branches     1895     4931    +3036     
==========================================
+ Hits          760     1709     +949     
- Misses       1100     3165    +2065     
- Partials       35       57      +22     

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

Copy link
Contributor

@ShahakShama ShahakShama 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, 6 unresolved discussions (waiting on @eitanm-starkware)


crates/papyrus_network/src/bin/network_stress_test/converters.rs line 8 at r1 (raw file):

    pub payload: Vec<u8>,
    pub time: SystemTime,
}

newline


crates/papyrus_network/src/bin/network_stress_test/converters.rs line 33 at r1 (raw file):

    fn from(mut value: Vec<u8>) -> Self {
        let vec_size = value.len();
        let payload_size = vec_size - 16;

Extract to a constant, and calculate it by using https://doc.rust-lang.org/std/mem/fn.size_of.html and addition


crates/papyrus_network/src/bin/network_stress_test/utils.rs line 18 at r1 (raw file):

    pub network_config: NetworkConfig,
    pub buffer_size: usize,
    pub payload_size: usize,

Rename to message_size, and reduce the metadata size from it before using it to define the payload (use the constant from previous comment)


crates/papyrus_network/src/bin/network_stress_test/utils.rs line 19 at r1 (raw file):

    pub buffer_size: usize,
    pub payload_size: usize,
    pub message_amount: u32,

rename to num_messages


crates/papyrus_network/src/bin/network_stress_test/utils.rs line 86 at r1 (raw file):

}

pub fn system_time_to_millis<S>(time: &SystemTime, serializer: S) -> Result<S::Ok, S::Error>

This function both converts to u64 and serializes. IMO it shouldn't do both. If you disagree at least rename it to reflect that it does both


crates/papyrus_network/src/bin/network_stress_test/utils.rs line 93 at r1 (raw file):

        time.duration_since(UNIX_EPOCH).map_err(serde::ser::Error::custom)?;
    let millis =
        duration_since_epoch.as_secs() * 1000 + u64::from(duration_since_epoch.subsec_millis());

Why not `duration_since_epoch.as_millis()

Copy link
Contributor Author

@eitanm-starkware eitanm-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, 5 unresolved discussions (waiting on @ShahakShama)


crates/papyrus_network/src/bin/network_stress_test/converters.rs line 33 at r1 (raw file):

Previously, ShahakShama wrote…

Extract to a constant, and calculate it by using https://doc.rust-lang.org/std/mem/fn.size_of.html and addition

Done.


crates/papyrus_network/src/bin/network_stress_test/utils.rs line 19 at r1 (raw file):

Previously, ShahakShama wrote…

rename to num_messages

Done.


crates/papyrus_network/src/bin/network_stress_test/utils.rs line 86 at r1 (raw file):

Previously, ShahakShama wrote…

This function both converts to u64 and serializes. IMO it shouldn't do both. If you disagree at least rename it to reflect that it does both

Done.


crates/papyrus_network/src/bin/network_stress_test/utils.rs line 93 at r1 (raw file):

Previously, ShahakShama wrote…

Why not `duration_since_epoch.as_millis()

Done.

Comment on lines 1 to 4
use std::time::{Duration, SystemTime};

struct StressTestMessage {
id: u32,
payload: Vec<u8>,
time: SystemTime,
pub const METADATA_SIZE: usize = size_of::<SystemTime>() + size_of::<u32>();
Copy link

Choose a reason for hiding this comment

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

The size_of function is used but not imported. Please add use std::mem::size_of; to the imports at the top of the file.

Spotted by Graphite Reviewer

Is this helpful? React 👍 or 👎 to let us know.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

Copy link
Contributor

@ShahakShama ShahakShama 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 r2, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @eitanm-starkware and @graphite-app[bot])


crates/papyrus_network/src/bin/network_stress_test/utils.rs line 86 at r1 (raw file):

Previously, eitanm-starkware wrote…

Done.

This is not done


crates/papyrus_network/src/bin/network_stress_test/utils.rs line 93 at r1 (raw file):

Previously, eitanm-starkware wrote…

Done.

This is not done

Comment on lines 1 to 4
use std::time::{Duration, SystemTime};

struct StressTestMessage {
id: u32,
payload: Vec<u8>,
time: SystemTime,
pub const METADATA_SIZE: usize = size_of::<SystemTime>() + size_of::<u32>();
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

Comment on lines 129 to 130
let millis =
duration_since_epoch.as_millis() + u128::from(duration_since_epoch.subsec_millis());
Copy link

Choose a reason for hiding this comment

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

The as_millis() method already includes the subsec_millis portion of the duration. Adding subsec_millis() again results in double-counting the milliseconds component. The line should be simplified to just duration_since_epoch.as_millis().

Spotted by Graphite Reviewer

Is this helpful? React 👍 or 👎 to let us know.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

Copy link
Contributor

@ShahakShama ShahakShama 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 2 of 2 files at r3, 3 of 3 files at r4, 2 of 2 files at r5, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @graphite-app[bot])

Comment on lines 129 to 130
let millis =
duration_since_epoch.as_millis() + u128::from(duration_since_epoch.subsec_millis());
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

Copy link
Contributor

@ShahakShama ShahakShama 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 r6, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @graphite-app[bot])

Copy link
Contributor

@ShahakShama ShahakShama 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, 2 unresolved discussions (waiting on @graphite-app[bot])

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