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

feat(starknet_gateway): create transaction generator towards benchmarking #2911

Merged
merged 2 commits into from
Jan 5, 2025

Conversation

ArniStarkware
Copy link
Contributor

No description provided.

@reviewable-StarkWare
Copy link

This change is Reviewable

Copy link
Contributor Author

ArniStarkware commented Dec 24, 2024

@ArniStarkware ArniStarkware marked this pull request as ready for review December 24, 2024 08:51
@ArniStarkware ArniStarkware force-pushed the arni/gateway/bench/create_txs_generator branch from a10fc80 to b486bb3 Compare December 24, 2024 08:58
@ArniStarkware ArniStarkware force-pushed the arni/gateway/bench/create_bench_file branch from 456c83f to b6d6af6 Compare December 24, 2024 10:02
@ArniStarkware ArniStarkware force-pushed the arni/gateway/bench/create_txs_generator branch 2 times, most recently from 21de3b5 to 3305dd6 Compare December 24, 2024 11:29
@ArniStarkware ArniStarkware force-pushed the arni/gateway/bench/create_bench_file branch from b6d6af6 to cdc7718 Compare December 25, 2024 08:26
@ArniStarkware ArniStarkware force-pushed the arni/gateway/bench/create_txs_generator branch from 3305dd6 to e4fac15 Compare December 25, 2024 08:26
@ArniStarkware ArniStarkware force-pushed the arni/gateway/bench/create_bench_file branch 2 times, most recently from 17f602a to 165237b Compare December 25, 2024 12:01
@ArniStarkware ArniStarkware force-pushed the arni/gateway/bench/create_txs_generator branch from e4fac15 to a6f5f98 Compare December 25, 2024 12:01
@ArniStarkware ArniStarkware changed the base branch from arni/gateway/bench/create_bench_file to arni/gateway/bench/business_logic December 25, 2024 12:01
Copy link

Benchmark movements:
full_committer_flow performance regressed!
full_committer_flow time: [30.068 ms 30.144 ms 30.225 ms]
change: [+1.1724% +1.4805% +1.8053%] (p = 0.00 < 0.05)
Performance has regressed.
Found 1 outliers among 100 measurements (1.00%)
1 (1.00%) high severe

@ArniStarkware ArniStarkware force-pushed the arni/gateway/bench/business_logic branch from 584ab22 to e151662 Compare December 25, 2024 12:40
@ArniStarkware ArniStarkware force-pushed the arni/gateway/bench/create_txs_generator branch from a6f5f98 to 7ed8632 Compare December 25, 2024 12:40
@ArniStarkware ArniStarkware force-pushed the arni/gateway/bench/business_logic branch from e151662 to 58b1254 Compare December 25, 2024 12:52
@ArniStarkware ArniStarkware force-pushed the arni/gateway/bench/create_txs_generator branch from 7ed8632 to ce1576d Compare December 25, 2024 12:52
Copy link
Contributor

@yair-starkware yair-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 6 of 6 files at r1, all commit messages.
Reviewable status: all files reviewed, 11 unresolved discussions (waiting on @alonh5, @ArniStarkware, and @Yael-Starkware)


crates/starknet_gateway/src/gateway.rs line 29 at r1 (raw file):

pub mod gateway_test;

pub struct GatewayBusinessLogic {

Why not pub(crate)?

Code quote:

pub

crates/starknet_gateway/src/gateway.rs line 79 at r1 (raw file):

pub struct Gateway {
    pub mempool_client: SharedMempoolClient,
    pub business_logic: GatewayBusinessLogic,

Why not pub(crate)?

Code quote:

pub

crates/starknet_gateway/bench/gateway_bench.rs line 15 at r1 (raw file):

use starknet_gateway::bench_test_utils::{BenchTestSetup, BenchTestSetupConfig};

pub fn declare_benchmark(c: &mut Criterion) {

Can these functions not be pub?

Code quote:

pub

crates/starknet_gateway/bench/gateway_bench.rs line 28 at r1 (raw file):

    let test_setup = BenchTestSetup::new(tx_generator_config);
    c.bench_with_input(BenchmarkId::new("invoke", n_txs), &test_setup, |b, s| {

Can you give meaningful names?

Code quote:

b, s

crates/starknet_gateway/src/bench_test_utils.rs line 49 at r1 (raw file):

    sender_address: ContractAddress,
    test_contract_address: ContractAddress,
}

Can we reuse AccountTransactionGenerator from sn_api_test_utils?

Code quote:

struct TransactionGenerator {
    nonce_manager: NonceManager,
    sender_address: ContractAddress,
    test_contract_address: ContractAddress,
}

crates/starknet_gateway/src/bench_test_utils.rs line 71 at r1 (raw file):

}

impl BenchTestSetup {

Move the impl closer to the struct

Code quote:

impl BenchTestSetup

crates/starknet_gateway/src/bench_test_utils.rs line 73 at r1 (raw file):

impl BenchTestSetup {
    pub fn new(config: BenchTestSetupConfig) -> Self {
        let cairo_version = CairoVersion::Cairo0;

Why Cairo0?

Code quote:

Cairo0

crates/starknet_gateway/src/lib.rs line 1 at r1 (raw file):

#[cfg(any(feature = "testing", test))]

Why testing?

Code quote:

#[cfg(any(feature = "testing", test))]

crates/starknet_gateway/src/lib.rs line 2 at r1 (raw file):

#[cfg(any(feature = "testing", test))]
pub mod bench_test_utils;

Why pub?

Code quote:

pub mod bench_test_utils;

crates/starknet_gateway/src/lib.rs line 14 at r1 (raw file):

mod rpc_state_reader_test;
pub mod state_reader;
#[cfg(any(feature = "testing", test))]

Why testing?

Code quote:

#[cfg(any(feature = "testing", test))]

crates/starknet_gateway/Cargo.toml line 58 at r1 (raw file):

name = "gateway_bench"
path = "bench/gateway_bench.rs"
required-features = ["testing"]

Why do we need this?

Code quote:

required-features = ["testing"]

@ArniStarkware ArniStarkware force-pushed the arni/gateway/bench/business_logic branch from 58b1254 to 416c277 Compare December 26, 2024 11:49
@ArniStarkware ArniStarkware force-pushed the arni/gateway/bench/create_txs_generator branch from ce1576d to 085ed84 Compare December 26, 2024 11:49
@ArniStarkware ArniStarkware changed the base branch from arni/gateway/bench/business_logic to arni/gateway/bench/create_bench_file December 26, 2024 11:49
@ArniStarkware ArniStarkware force-pushed the arni/gateway/bench/create_txs_generator branch from c7fc216 to ec3911a Compare January 5, 2025 08:55
@ArniStarkware ArniStarkware changed the base branch from arni/gateway/revert/gateway_bl to main January 5, 2025 08:55
Copy link
Contributor Author

@ArniStarkware ArniStarkware 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 @Yael-Starkware and @yair-starkware)


crates/starknet_gateway/src/lib.rs line 12 at r7 (raw file):

Previously, alonh5 (Alon Haramati) wrote…

Instead of removing this can you add a "testing" feature and use it in the bench?

@yair-starkware - This is at odds with our discussions on the topic.

IIUC, the feature "testing" is about sharing utilities that other crates can use for testing. For example, starknet_api has a test_utils module in the "testing" feature so that the test utils can be used in the gateway's tests.
This is not the case here. Here are the utils used to test this specific crate.
Also, see this that indicates that the benchmark is not considered a test.

We can also create another feature, for example, "bench-testing." Or we can decide it is not an issue to have all this code in the "testing" feature - as, indeed, the bench is an external code that uses code from the module for testing purposes.

@yair-starkware
Copy link
Contributor

crates/starknet_gateway/src/lib.rs line 12 at r7 (raw file):

Previously, ArniStarkware (Arnon Hod) wrote…

@yair-starkware - This is at odds with our discussions on the topic.

IIUC, the feature "testing" is about sharing utilities that other crates can use for testing. For example, starknet_api has a test_utils module in the "testing" feature so that the test utils can be used in the gateway's tests.
This is not the case here. Here are the utils used to test this specific crate.
Also, see this that indicates that the benchmark is not considered a test.

We can also create another feature, for example, "bench-testing." Or we can decide it is not an issue to have all this code in the "testing" feature - as, indeed, the bench is an external code that uses code from the module for testing purposes.

Is it possible to make it an inner module of the bench test?

@ArniStarkware ArniStarkware requested a review from alonh5 January 5, 2025 10:04
Copy link
Contributor Author

@ArniStarkware ArniStarkware 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: 5 of 7 files reviewed, 1 unresolved discussion (waiting on @alonh5, @Yael-Starkware, and @yair-starkware)


crates/starknet_gateway/src/lib.rs line 12 at r7 (raw file):

Previously, yair-starkware (Yair) wrote…

Is it possible to make it an inner module of the bench test?

It is possible to move the bench_test_utils to be an inner module of the bench test. We still have to address the visibility of state_reader_test_utils. This state reader is used for this bench.

Copy link
Collaborator

@alonh5 alonh5 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: 5 of 7 files reviewed, 1 unresolved discussion (waiting on @ArniStarkware, @Yael-Starkware, and @yair-starkware)


crates/starknet_gateway/src/lib.rs line 12 at r7 (raw file):

Previously, ArniStarkware (Arnon Hod) wrote…

It is possible to move the bench_test_utils to be an inner module of the bench test. We still have to address the visibility of state_reader_test_utils. This state reader is used for this bench.

This is testing code, even if other crates currently don't use it. If it's possible please add the "testing" feature and use it in the bench.

@ArniStarkware ArniStarkware force-pushed the arni/gateway/bench/create_txs_generator branch from ec3911a to 9eb4575 Compare January 5, 2025 12:30
@ArniStarkware
Copy link
Contributor Author

crates/starknet_gateway/src/lib.rs line 12 at r7 (raw file):

Previously, alonh5 (Alon Haramati) wrote…

This is testing code, even if other crates currently don't use it. If it's possible please add the "testing" feature and use it in the bench.

Done.

Copy link
Collaborator

@alonh5 alonh5 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 2 files at r8, 2 of 3 files at r9, 4 of 4 files at r10, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @Yael-Starkware and @yair-starkware)

Copy link
Contributor

@yair-starkware yair-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 r8.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @Yael-Starkware)


crates/starknet_gateway/src/lib.rs line 12 at r7 (raw file):

Previously, ArniStarkware (Arnon Hod) wrote…

Done.

I don't want to be too pedantic, but benchmarking is not testing.
You can collect benchmark data and test for regressions.

@ArniStarkware ArniStarkware force-pushed the arni/gateway/bench/create_txs_generator branch from 9eb4575 to 392dca6 Compare January 5, 2025 12:56
@ArniStarkware ArniStarkware requested a review from alonh5 January 5, 2025 13:11
Copy link
Contributor Author

@ArniStarkware ArniStarkware 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: 3 of 9 files reviewed, 1 unresolved discussion (waiting on @alonh5, @ArniStarkware, and @Yael-Starkware)


crates/starknet_gateway/src/lib.rs line 13 at r12 (raw file):

pub mod state_reader;
#[cfg(any(feature = "testing", test))]
pub mod state_reader_test_utils;

TODO: Move to mempool test utils.
Per our latest discussion.
We agreed this is non-blocking.

@alonh5 @yair-starkware

Code quote:

#[cfg(any(feature = "testing", test))]
pub mod state_reader_test_utils;

Copy link
Collaborator

@alonh5 alonh5 left a comment

Choose a reason for hiding this comment

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

Reviewed 3 of 5 files at r11, 1 of 6 files at r12.
Reviewable status: 4 of 9 files reviewed, 1 unresolved discussion (waiting on @ArniStarkware and @Yael-Starkware)

alonh5
alonh5 previously requested changes Jan 5, 2025
Copy link
Collaborator

@alonh5 alonh5 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 6 files at r12, all commit messages.
Reviewable status: 5 of 9 files reviewed, 2 unresolved discussions (waiting on @ArniStarkware and @Yael-Starkware)


crates/starknet_gateway/bench/bench_lib.rs line 1 at r12 (raw file):

//! Benchmark module for the starknet gateway crate. It provides functionalities to benchmark

Why do we need this module and not just have the utils in bench/?

@ArniStarkware ArniStarkware force-pushed the arni/gateway/bench/create_txs_generator branch from 392dca6 to 9eb4575 Compare January 5, 2025 15:54
@ArniStarkware
Copy link
Contributor Author

crates/starknet_gateway/bench/bench_lib.rs line 1 at r12 (raw file):

Previously, alonh5 (Alon Haramati) wrote…

Why do we need this module and not just have the utils in bench/?

Reverted.

@ArniStarkware ArniStarkware requested a review from alonh5 January 5, 2025 15:58
Copy link
Contributor Author

@ArniStarkware ArniStarkware left a comment

Choose a reason for hiding this comment

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

Dismissed @alonh5 from a discussion.
Reviewable status: 5 of 9 files reviewed, all discussions resolved (waiting on @alonh5 and @Yael-Starkware)

Copy link
Contributor Author

@ArniStarkware ArniStarkware 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 r8, 2 of 6 files at r12, 3 of 4 files at r13, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @alonh5 and @Yael-Starkware)

@ArniStarkware ArniStarkware added this pull request to the merge queue Jan 5, 2025
Merged via the queue into main with commit 97e7650 Jan 5, 2025
38 checks passed
@ArniStarkware ArniStarkware deleted the arni/gateway/bench/create_txs_generator branch January 5, 2025 16:48
@github-actions github-actions bot locked and limited conversation to collaborators Jan 7, 2025
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