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: Add lotus-bench cli option to stress test any binary #11270

Merged
merged 2 commits into from
Sep 28, 2023

Conversation

fridrik01
Copy link
Contributor

Related Issues

Written to help with solving #11251
Extension to the RPC benchmark introduced in #10761

Proposed Changes

This PR extends the RPC benchmark to support running any binary and analyze their latency and histogram distribution, track most common errors, perform stress testing under different concurrency levels and see how it works under different QPS.

Test plan

Lets say you want to understand how lotus-shed mpool miner-select-messages behaves over time.

You can use this new lotus-bench cli tool to achieve this, for example the following command runs the command using a single thread (concurrency=1) at 1 qps and provides a realtime updated latency/histogram UI and it runs for 24 hours.

lotus-bench cli --cmd='lotus-shed mpool miner-select-messages' --concurrency=1 --qps=1 --watch=5s --duration=24h

It will produce something like:
image

Additional Info

This works exactly the same as the rpc benchmark, which has a detailed summary (see PR)

Checklist

Before you mark the PR ready for review, please make sure that:

  • Commits have a clear commit message.
  • PR title is in the form of of <PR type>: <area>: <change being made>
    • example: fix: mempool: Introduce a cache for valid signatures
    • PR type: fix, feat, build, chore, ci, docs, perf, refactor, revert, style, test
    • area, e.g. api, chain, state, market, mempool, multisig, networking, paych, proving, sealing, wallet, deps
  • If the PR affects users (e.g., new feature, bug fix, system requirements change), update the CHANGELOG.md and add details to the UNRELEASED section.
  • New features have usage guidelines and / or documentation updates in
  • Tests exist for new functionality or change in behavior
  • CI is green

@fridrik01 fridrik01 marked this pull request as ready for review September 15, 2023 14:16
@fridrik01 fridrik01 requested a review from a team as a code owner September 15, 2023 14:16
Copy link
Member

@Stebalien Stebalien left a comment

Choose a reason for hiding this comment

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

This seems generally useful but an odd addition to lotus-bench given that it's general-purpose.

It looks like you'd be better off with something like https://github.com/sharkdp/hyperfine (available in pretty much every package manager)


Here are some real examples:
lotus-bench cli --cmd='lotus-shed mpool miner-select-messages' // runs the command with default concurrency and qps
lotus-bench cli --cmd='lotus-shed mpool miner-select-messages:3' // override concurrency to 3
Copy link
Member

Choose a reason for hiding this comment

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

Using : could cause issues down the road (for any command including a literal :. Why not just rely on the flags?

Also, for the command, I'd suggest using positional parameters. I.e., "the rest of the args".

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 here.

@fridrik01
Copy link
Contributor Author

This seems generally useful but an odd addition to lotus-bench given that it's general-purpose.

It looks like you'd be better off with something like https://github.com/sharkdp/hyperfine (available in pretty much every package manager)

Yes, this could be an independent general purpose tool but I put it here for a lack of a better place to put it as it already shares many of the same code when stress testing our RPC endpoints, and this would enable us to do the same by stress testing lotus backend through our different cli commands.

I am not familiar with hyperfine but this does seem different enough as its based on generating specific workloads for a certain duration where you can tune the concurrency/qps for each independently and then get simple histogram/latency distribution.

Copy link
Contributor

@arajasek arajasek left a comment

Choose a reason for hiding this comment

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

This LGTM, and I'm personally happy to land as-is. @magik6k do you wanna weigh in too?


Here are some real examples:
lotus-bench cli --cmd='lotus-shed mpool miner-select-messages' // runs the command with default concurrency and qps
lotus-bench cli --cmd='lotus-shed mpool miner-select-messages:3' // override concurrency to 3
Copy link
Contributor

Choose a reason for hiding this comment

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

+1 here.

cmd/lotus-bench/cli.go Outdated Show resolved Hide resolved
@magik6k
Copy link
Contributor

magik6k commented Sep 22, 2023

@magik6k do you wanna weigh in too?

Didn't review, but I'm fine with this landing

@fridrik01 fridrik01 merged commit 3fd57ff into master Sep 28, 2023
87 checks passed
@fridrik01 fridrik01 deleted the benchmark-binaries branch September 28, 2023 10:15
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.

None yet

4 participants