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

Problem: configs are baked in testground #1561

Merged
merged 10 commits into from
Sep 12, 2024

Conversation

mmsqe
Copy link
Collaborator

@mmsqe mmsqe commented Aug 30, 2024

👮🏻👮🏻👮🏻 !!!! REFERENCE THE PROBLEM YOUR ARE SOLVING IN THE PR TITLE AND DESCRIBE YOUR SOLUTION HERE !!!! DO NOT FORGET !!!! 👮🏻👮🏻👮🏻

PR Checklist:

  • Have you read the CONTRIBUTING.md?
  • Does your PR follow the C4 patch requirements?
  • Have you rebased your work on top of the latest master?
  • Have you checked your code compiles? (make)
  • Have you included tests for any non-trivial functionality?
  • Have you checked your code passes the unit tests? (make test)
  • Have you checked your code formatting is correct? (go fmt)
  • Have you checked your basic code style is fine? (golangci-lint run)
  • If you added any dependencies, have you checked they do not contain any known vulnerabilities? (go list -json -m all | nancy sleuth)
  • If your changes affect the client infrastructure, have you run the integration test?
  • If your changes affect public APIs, does your PR follow the C4 evolution of public contracts?
  • If your code changes public APIs, have you incremented the crate version numbers and documented your changes in the CHANGELOG.md?
  • If you are contributing for the first time, please read the agreement in CONTRIBUTING.md now and add a comment to this pull request stating that your PR is in accordance with the Developer's Certificate of Origin.

Thank you for your code, it's appreciated! :)

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Introduced a new command-line argument --num_max_workers for enhanced control over concurrency during testing.
    • Added a new configuration parameter num_max_workers in the benchmark settings for improved transaction processing flexibility.
    • Enhanced load generation functionality to utilize the specified maximum number of workers.
    • Improved timestamp handling and transaction performance metrics in benchmarking reports.
    • Added new methods for calculating transactions per second (TPS) and truncating fractional seconds in timestamp reporting.
    • Enhanced configuration handling in the gen function for more granular control over node and application settings.
  • Bug Fixes

    • Improved handling of concurrency parameters in various benchmark functions for better performance and resource management.

@mmsqe mmsqe requested a review from a team as a code owner August 30, 2024 01:36
@mmsqe mmsqe requested review from JayT106 and calvinaco and removed request for a team August 30, 2024 01:36
Copy link
Contributor

coderabbitai bot commented Aug 30, 2024

Walkthrough

The changes introduce a new command-line argument, --num_max_workers, across multiple files in the testground benchmark suite. This parameter allows users to specify the maximum number of worker threads for concurrent transaction processing. Modifications include updates to function signatures, internal logic adjustments, and the addition of a configuration parameter in the local.toml file, enhancing the configurability and scalability of the benchmarking process.

Changes

File Path Change Summary
testground/README.md Added --num_max_workers parameter to the command for running stateless test cases.
testground/benchmark/benchmark/main.py Modified entrypoint function to include ctx.params.num_max_workers in generate_load call.
testground/benchmark/benchmark/params.py Introduced num_max_workers property method to retrieve maximum workers from test_instance_params.
testground/benchmark/benchmark/sendtx.py Updated generate_load function to accept num_max_workers, replacing hardcoded num_accounts.
testground/benchmark/benchmark/stateless.py Added num_max_workers parameter to gen and patch_configs_local functions.
testground/benchmark/benchmark/peer.py Modified patch_configs function to include config_patch and app_patch parameters.
testground/benchmark/compositions/local.toml Introduced num_max_workers configuration parameter set to "3000".

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI
    participant Main
    participant LoadGenerator
    participant Params

    User->>CLI: Run command with --num_max_workers
    CLI->>Main: Pass num_max_workers
    Main->>Params: Retrieve num_max_workers
    Main->>LoadGenerator: Call generate_load with num_max_workers
    LoadGenerator->>LoadGenerator: Execute load generation with specified workers
Loading

🐇 "In the meadow, I hop and play,
New threads join the fray today!
With workers plenty, we’ll send with glee,
Transactions flying, oh what a spree!
Configured well, we dance and cheer,
In our benchmark world, we’ve nothing to fear!" 🐇

Possibly related PRs

  • Problem: no cluster benchmarking #1431: This PR modifies the testground/benchmark/benchmark/stateless.py file, which is also altered in the main PR, specifically regarding the handling of configuration parameters.

Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ac32495 and 013d2f5.

Files selected for processing (1)
  • testground/benchmark/benchmark/stateless.py (4 hunks)
Additional context used
Ruff
testground/benchmark/benchmark/stateless.py

50-50: Do not use mutable data structures for argument defaults

Replace with None; initialize within function

(B006)


51-51: Do not use mutable data structures for argument defaults

Replace with None; initialize within function

(B006)

Additional comments not posted (4)
testground/benchmark/benchmark/stateless.py (4)

76-76: LGTM!

The changes to the patch_configs_local function call, passing the config_patch and app_patch arguments, are consistent with the updated function signature.


85-86: LGTM!

The changes to the patch_configs_local function call, passing the config_patch and app_patch arguments, are consistent with the updated function signature.


276-277: LGTM!

The changes to the patch_configs_local function signature, adding the config_patch and app_patch parameters, enhance the configurability of the function and align with the AI-generated summary.


282-282: LGTM!

The changes to the patch_configs function call, passing the config_patch and app_patch arguments, are consistent with the overall theme of enhancing configurability.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between eb0a15d and 2f23334.

Files selected for processing (6)
  • testground/README.md (1 hunks)
  • testground/benchmark/benchmark/main.py (1 hunks)
  • testground/benchmark/benchmark/params.py (1 hunks)
  • testground/benchmark/benchmark/sendtx.py (1 hunks)
  • testground/benchmark/benchmark/stateless.py (3 hunks)
  • testground/benchmark/compositions/local.toml (1 hunks)
Additional context used
LanguageTool
testground/README.md

[style] ~95-~95: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...ccounts for each full node. * num_txs is the number of test transactions to be s...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~96-~96: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... each test account. * num_max_workers is the number of worker threads to use for...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)

Additional comments not posted (5)
testground/benchmark/compositions/local.toml (1)

19-20: LGTM!

The addition of the num_max_workers parameter is correctly implemented and provides flexibility for configuring the concurrency level.

testground/benchmark/benchmark/main.py (1)

39-41: LGTM!

The modification correctly passes the num_max_workers parameter to the generate_load function, enhancing the load generation process.

testground/benchmark/benchmark/sendtx.py (1)

80-85: LGTM!

The modification correctly enhances the flexibility of the generate_load function by allowing the caller to specify the maximum number of workers.

testground/benchmark/benchmark/stateless.py (2)

Line range hint 50-95: LGTM! Verify the default value.

The addition of the num_max_workers parameter is correctly implemented. Ensure that the default value of 3000 is appropriate for your use case.


157-162: LGTM! Verify the generate_load function.

The addition of the num_max_workers parameter is correctly implemented. Ensure that the generate_load function handles the parameter correctly.

testground/README.md Outdated Show resolved Hide resolved
testground/benchmark/benchmark/params.py Outdated Show resolved Hide resolved
Copy link

codecov bot commented Aug 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 15.24%. Comparing base (7b402ef) to head (013d2f5).
Report is 1 commits behind head on main.

❗ There is a different number of reports uploaded between BASE (7b402ef) and HEAD (013d2f5). Click for more details.

HEAD has 12 uploads less than BASE
Flag BASE (7b402ef) HEAD (013d2f5)
2 0
integration_tests 20 10
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##             main    #1561       +/-   ##
===========================================
- Coverage   36.12%   15.24%   -20.89%     
===========================================
  Files          97       67       -30     
  Lines        7725     4874     -2851     
===========================================
- Hits         2791      743     -2048     
+ Misses       4585     4037      -548     
+ Partials      349       94      -255     

see 47 files with indirect coverage changes

testground/README.md Outdated Show resolved Hide resolved
@yihuang
Copy link
Collaborator

yihuang commented Aug 30, 2024

3 7 testplan-{index} 200 15 3000

what is the meaning of the fields?

@mmsqe
Copy link
Collaborator Author

mmsqe commented Aug 30, 2024

3000

validator_count:   3
fullnode_count:    7
num_accounts:      200
num_txs:           15
num_max_workers:   3000

@yihuang
Copy link
Collaborator

yihuang commented Aug 30, 2024

3000

validator_count:   3
fullnode_count:    7
num_accounts:      200
num_txs:           15
num_max_workers:   3000

what's the point of setting thread pool size larger than accounts, there's only one task for each account.

@mmsqe mmsqe changed the title Problem: no num_max_workers to handle tx sending concurrency Problem: block_stm_workers is not configurable Sep 9, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range, codebase verification and nitpick comments (1)
testground/benchmark/benchmark/stateless.py (1)

317-327: Add test cases for truncate_fractional_seconds function.

The truncate_fractional_seconds function is used in timestamp processing but lacks test cases to verify its correctness. It is crucial to add test cases covering various timestamp formats and edge cases to ensure the function's reliability and accuracy in time-based operations.

  • Consider adding test cases for different timestamp formats and edge cases.
Analysis chain

Approve the addition of truncate_fractional_seconds function.

The truncate_fractional_seconds function has been correctly implemented to handle timestamp formatting by truncating fractional seconds. This addition enhances the consistency of timestamp handling across the system.

Verify that the truncate_fractional_seconds function correctly handles various timestamp formats and does not introduce errors in timestamp processing.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness and impact of the `truncate_fractional_seconds` function on timestamp processing.

# Test: Search for the function usage and test cases. Expect: Correct handling of various timestamp formats.
rg --type py 'truncate_fractional_seconds' -A 10

Length of output: 1704


Script:

#!/bin/bash
# Description: Search for test cases or additional usage of the `truncate_fractional_seconds` function in the codebase.

# Search for test cases in Python test files.
rg --type py 'truncate_fractional_seconds' --glob '*test*.py' -A 10

# Search for additional usage of the function in the codebase.
rg --type py 'truncate_fractional_seconds' -A 10

Length of output: 1772

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2f23334 and 5d4aedf.

Files selected for processing (2)
  • testground/benchmark/benchmark/peer.py (2 hunks)
  • testground/benchmark/benchmark/stateless.py (6 hunks)
Additional comments not posted (4)
testground/benchmark/benchmark/peer.py (1)

Line range hint 119-139: Approve the addition of block_stm_workers parameter.

The changes to the patch_configs function correctly introduce the block_stm_workers parameter and use it to set the "evm.block-stm-workers" configuration. This aligns with the PR's objectives to manage concurrency.

Ensure that the "evm.block-stm-workers" configuration key is supported and correctly utilized across the system. Consider running integration tests to verify its impact on the blockchain's performance and stability.

testground/benchmark/benchmark/stateless.py (3)

Line range hint 52-95: Approve the addition of block_stm_workers parameter to gen function.

The gen function has been correctly updated to include the block_stm_workers parameter, enhancing its configurability for concurrency management. This parameter is appropriately passed to patch_configs_local.

Verify that the block_stm_workers parameter is handled correctly in patch_configs_local and that it effectively influences the system's concurrency management.

Verification successful

Verification Successful: block_stm_workers Parameter Handling in patch_configs_local

The block_stm_workers parameter is correctly passed and utilized within the patch_configs_local function, specifically in the call to patch_configs. This confirms its role in managing concurrency settings as intended.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the handling of the `block_stm_workers` parameter in `patch_configs_local`.

# Test: Search for the function definition and usage. Expect: Correct handling of the parameter.
rg --type py 'patch_configs_local' -A 10

Length of output: 2281


Script:

#!/bin/bash
# Description: Verify the usage of the `block_stm_workers` parameter within the `patch_configs_local` function.

# Test: Search for the usage of `block_stm_workers` within the function body.
rg --type py 'def patch_configs_local' -A 50 | rg 'block_stm_workers'

Length of output: 262


330-346: Approve the addition of calculate_tps function.

The calculate_tps function has been correctly implemented to calculate transactions per second based on block timestamps. This addition enhances the module's ability to analyze transaction performance metrics.

Verify that the calculate_tps function correctly calculates TPS and handles edge cases such as zero time difference or invalid timestamps.


287-292: Approve the modification of patch_configs_local to include block_stm_workers.

The patch_configs_local function has been correctly updated to include the block_stm_workers parameter, ensuring that the concurrency management setting is propagated to the patch_configs function.

Verify that the block_stm_workers parameter is correctly utilized in the patch_configs function and that it effectively influences the system's concurrency management.

Verification successful

The block_stm_workers parameter is correctly utilized in the patch_configs function.

The parameter is used to set the "evm.block-stm-workers" configuration in the app.toml file, ensuring that the concurrency management setting is effectively applied.

  • Location: testground/benchmark/benchmark/peer.py in the patch_configs function.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the propagation and usage of the `block_stm_workers` parameter in the `patch_configs` function.

# Test: Search for the function definition and usage. Expect: Correct handling of the parameter.
rg --type py 'patch_configs' -A 10

Length of output: 5372


Script:

#!/bin/bash
# Description: Verify the usage of the `block_stm_workers` parameter within the `patch_configs` function.

# Test: Search for the usage of `block_stm_workers` in the `patch_configs` function.
rg --type py 'block_stm_workers' -A 10 -B 10 testground/benchmark/benchmark/peer.py

Length of output: 1359

allow overwrite config and app patch
@mmsqe mmsqe changed the title Problem: block_stm_workers is not configurable Problem: configs are baked in testground Sep 12, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 5d4aedf and 9eb91ed.

Files selected for processing (2)
  • testground/benchmark/benchmark/peer.py (1 hunks)
  • testground/benchmark/benchmark/stateless.py (5 hunks)
Additional context used
Ruff
testground/benchmark/benchmark/stateless.py

51-58: Do not use mutable data structures for argument defaults

Replace with None; initialize within function

(B006)


59-68: Do not use mutable data structures for argument defaults

Replace with None; initialize within function

(B006)

Additional comments not posted (1)
testground/benchmark/benchmark/peer.py (1)

119-123: LGTM!

The changes to the patch_configs function look good. The modifications enhance the flexibility and customizability of the configuration management process by:

  1. Accepting config_patch and app_patch as parameters, allowing users to pass in their own configurations.
  2. Removing the hardcoded configuration dictionaries, aligning with the goal of making the configuration more dynamic.
  3. Retaining the line that sets "p2p.persistent_peers" based on the peers argument, ensuring that this specific configuration is still being updated correctly.

The changes are consistent with the AI-generated summary and do not introduce any apparent issues or code smells.

testground/benchmark/benchmark/stateless.py Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 9eb91ed and 3b45f7e.

Files selected for processing (1)
  • testground/benchmark/benchmark/stateless.py (5 hunks)
Additional context used
Ruff
testground/benchmark/benchmark/stateless.py

51-51: Do not use mutable data structures for argument defaults

Replace with None; initialize within function

(B006)


52-52: Do not use mutable data structures for argument defaults

Replace with None; initialize within function

(B006)

Additional comments not posted (5)
testground/benchmark/benchmark/stateless.py (5)

51-73: LGTM, the changes to introduce config_patch and app_patch parameters are approved.

The modifications to the gen function that introduce the config_patch and app_patch parameters are approved. These changes enhance the configurability and maintainability of the code by allowing users to specify detailed configuration options.

Tools
Ruff

51-51: Do not use mutable data structures for argument defaults

Replace with None; initialize within function

(B006)


52-52: Do not use mutable data structures for argument defaults

Replace with None; initialize within function

(B006)


51-73: The past review comment regarding the mutable default arguments issue is still valid and applicable to the current code segment. Please refer to the previous comment for the detailed explanation and proposed fix.

Tools
Ruff

51-51: Do not use mutable data structures for argument defaults

Replace with None; initialize within function

(B006)


52-52: Do not use mutable data structures for argument defaults

Replace with None; initialize within function

(B006)


54-73: LGTM!

The changes to introduce default_config_patch and default_app_patch constants for defining the default configuration patches are approved. This improves the readability and maintainability of the code.

The use of the spread operator to merge the default patches with the user-provided config_patch and app_patch is also correct and gives precedence to the user-provided values.


Line range hint 97-107: LGTM!

The changes to pass the updated config_patch and app_patch arguments to the patch_configs_local function are approved. This change is consistent with the modifications made to the gen function to introduce the config_patch and app_patch parameters.


297-303: LGTM!

The changes to the patch_configs_local function to accept the config_patch and app_patch arguments and pass them to the patch_configs function are approved. These changes are consistent with the modifications made to the gen function and ensure that the configuration patches are applied properly.

testground/benchmark/benchmark/stateless.py Show resolved Hide resolved
@mmsqe mmsqe requested a review from yihuang September 12, 2024 08:00
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3b45f7e and ac32495.

Files selected for processing (2)
  • testground/benchmark/benchmark/peer.py (2 hunks)
  • testground/benchmark/benchmark/stateless.py (4 hunks)
Files skipped from review as they are similar to previous changes (1)
  • testground/benchmark/benchmark/peer.py
Additional comments not posted (3)
testground/benchmark/benchmark/stateless.py (3)

76-76: LGTM!

The changes to pass the config_patch and app_patch arguments to the patch_configs_local function are consistent with its signature and look good to me.

Also applies to: 85-86


276-277: LGTM!

The addition of config_patch and app_patch parameters to the patch_configs_local function enhances its configurability and allows for more granular control over the configuration settings. These changes look good to me.


282-282: LGTM!

The change to pass the config_patch and app_patch arguments to the patch_configs function is consistent with its updated signature and looks good to me.

testground/benchmark/benchmark/stateless.py Outdated Show resolved Hide resolved
testground/benchmark/benchmark/stateless.py Outdated Show resolved Hide resolved
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