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: block-stm has bad worst case performance #1570

Merged
merged 2 commits into from
Sep 12, 2024

Conversation

yihuang
Copy link
Collaborator

@yihuang yihuang commented Sep 11, 2024

Solution:

  • support optional pre-estimate logic to improve worst case performance, in the cost of optimal case performance.

Benchmark Results

  • account 1 (worst case)
$ benchstat /tmp/before /tmp/after
goos: darwin
goarch: arm64
pkg: github.com/crypto-org-chain/cronos/v2/app
                                │  /tmp/before  │             /tmp/after             │
                                │    sec/op     │   sec/op     vs base               │
ERC20Transfer/memiavl-stm-16-16   1533.1m ± 11%   677.5m ± 2%  -55.81% (p=0.002 n=6)

                                │  /tmp/before  │             /tmp/after              │
                                │     B/op      │     B/op      vs base               │
ERC20Transfer/memiavl-stm-16-16   7316.8Mi ± 5%   532.6Mi ± 0%  -92.72% (p=0.002 n=6)

                                │  /tmp/before  │             /tmp/after             │
                                │   allocs/op   │  allocs/op   vs base               │
ERC20Transfer/memiavl-stm-16-16   120.871M ± 5%   6.488M ± 0%  -94.63% (p=0.002 n=6)
  • account 100
goos: darwin
goarch: arm64
pkg: github.com/crypto-org-chain/cronos/v2/app
                                │ /tmp/before │             /tmp/after             │
                                │   sec/op    │   sec/op     vs base               │
ERC20Transfer/memiavl-stm-16-16   122.5m ± 1%   141.3m ± 3%  +15.29% (p=0.002 n=6)

                                │ /tmp/before  │          /tmp/after           │
                                │     B/op     │     B/op      vs base         │
ERC20Transfer/memiavl-stm-16-16   493.8Mi ± 0%   493.1Mi ± 0%  ~ (p=0.485 n=6)

                                │ /tmp/before │            /tmp/after             │
                                │  allocs/op  │  allocs/op   vs base              │
ERC20Transfer/memiavl-stm-16-16   6.259M ± 0%   6.195M ± 0%  -1.02% (p=0.002 n=6)

👮🏻👮🏻👮🏻 !!!! 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

  • New Features

    • Introduced a pre-estimate block-stm option to enhance worst-case performance.
    • Added a new parameter for block-stm executor configuration, improving application behavior during execution.
  • Bug Fixes

    • No bugs introduced or existing functionalities altered.
  • Documentation

    • Updated CHANGELOG.md to reflect recent enhancements and changes.
  • Chores

    • Updated dependency versions to ensure alignment with the latest libraries and improvements.

Copy link
Contributor

coderabbitai bot commented Sep 11, 2024

Walkthrough

The changes introduce a new pre-estimate block-stm option aimed at enhancing worst-case performance in the application. The New function in app/app.go has been modified to include this new parameter, impacting the configuration of the block-stm executor. Additionally, a constant for block-stm pre-estimation has been added to the benchmarking tests. Dependency versions have been updated in both go.mod and gomod2nix.toml, ensuring alignment with the latest libraries.

Changes

Files Change Summary
CHANGELOG.md Added entry for integrating pre-estimate block-stm option to improve worst-case performance.
app/app.go Modified New function to include preEstimate parameter for block-stm executor configuration.
app/bench_test.go Added constant BlockSTMPreEstimate for benchmarking control of block state machine pre-estimation.
go.mod, gomod2nix.toml Updated dependency versions for various modules to their latest versions.

Sequence Diagram(s)

sequenceDiagram
    participant A as Application
    participant B as BlockSTM Executor
    participant C as AppOptions

    A->>C: Retrieve preEstimate parameter
    C->>A: Return preEstimate value
    A->>B: Configure BlockSTM Executor with preEstimate
    B-->>A: Executor ready with new configuration
Loading

🐇 In a world of code and logic bright,
A new option hops into sight.
With pre-estimates, we aim to soar,
Improving performance, who could ask for more?
So let us cheer, both near and far,
For every change, a shining star! 🌟


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

codecov bot commented Sep 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 36.12%. Comparing base (5a3c38b) to head (fa14ebd).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1570   +/-   ##
=======================================
  Coverage   36.12%   36.12%           
=======================================
  Files          97       97           
  Lines        7725     7725           
=======================================
  Hits         2791     2791           
  Misses       4585     4585           
  Partials      349      349           

Solution:
- support optional pre-estimate logic to improve worst case performance,
  in the cost of optimal case performance.
@yihuang yihuang changed the title Problem: block-stm don't do pre-estimation Problem: block-stm has bad worst case performance Sep 11, 2024
@yihuang yihuang marked this pull request as ready for review September 11, 2024 12:11
@yihuang yihuang requested a review from a team as a code owner September 11, 2024 12:11
@yihuang yihuang requested review from mmsqe and devashishdxt and removed request for a team September 11, 2024 12:11
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

Outside diff range and nitpick comments (1)
CHANGELOG.md (1)

36-36: Changelog entry looks good!

The addition to the changelog is appropriate and documents a relevant change.

-* [#1570](https://github.com/crypto-org-chain/cronos/pull/1570) Integrate pre-estimate block-stm option to improve worst case performance.
+* [#1570](https://github.com/crypto-org-chain/cronos/pull/1570) Integrate pre-estimate block-stm option to improve worst-case performance.
Tools
LanguageTool

[uncategorized] ~36-~36: If this is a compound adjective that modifies the following noun, use a hyphen.
Context: ...re-estimate block-stm option to improve worst case performance. ### Bug Fixes * [#1520](...

(EN_COMPOUND_ADJECTIVE_INTERNAL)

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 5a3c38b and fa14ebd.

Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
Files selected for processing (5)
  • CHANGELOG.md (1 hunks)
  • app/app.go (2 hunks)
  • app/bench_test.go (2 hunks)
  • go.mod (3 hunks)
  • gomod2nix.toml (6 hunks)
Files skipped from review due to trivial changes (2)
  • go.mod
  • gomod2nix.toml
Additional context used
LanguageTool
CHANGELOG.md

[uncategorized] ~36-~36: If this is a compound adjective that modifies the following noun, use a hyphen.
Context: ...re-estimate block-stm option to improve worst case performance. ### Bug Fixes * [#1520](...

(EN_COMPOUND_ADJECTIVE_INTERNAL)

Additional comments not posted (1)
app/bench_test.go (1)

Line range hint 42-74: LGTM!

The changes introduce a new constant BlockSTMPreEstimate to configure the block state machine pre-estimation during benchmarking. The constant is set to false, disabling pre-estimation, and is used in a specific benchmarking scenario with memiavl-stm and different number of workers.

The changes are well-contained within the benchmarking function and do not affect the core application logic.

app/app.go Show resolved Hide resolved
@yihuang yihuang added this pull request to the merge queue Sep 12, 2024
Merged via the queue into crypto-org-chain:main with commit a6c9d58 Sep 12, 2024
37 checks passed
@yihuang yihuang deleted the dep-analysis branch September 12, 2024 02:38
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