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(tools/benchmark): introduce benchmark module (backport #22778) #22851

Merged
merged 4 commits into from
Dec 13, 2024

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Dec 12, 2024

Description

Introduces a benchmark module which I wrote to test store performance. It can be used to holistically test the end to end performance of a node. Given an initial configuration tools/benchmark provides:

  • A possibly enormous sequence of key-value sets in InitGenesis distributed across n storekeys, e.g. 20M keys across 5 store keys
  • A client which syncs to genesis state then deterministically generates txs which contain a configurable sequence of get, insert, update & delete operations
  • A keeper which processes the above transactions and emits some telemetry data about them.

Client invocation looks like:

simdv2 tx benchmark load-test --from bob --yes --ops 1000 --pause 10 -v

On exit it dumps the generator state so that running again should still be in sync. It assumes that any transaction accepted by the network was processed, which may not be the case, so miss rate will probably increase over time. This isn't really a problem for tests.

Obviously this module is built to DOS a node by testing the upper bounds of chain performance; I had massively increase gas limits in tests, so it shouldn't be included by default. It's enabled in simapp and simapp/v2 in this PR though.

closes #750


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title, you can find examples of the prefixes below:

  • confirmed ! in the type prefix if API or client breaking change

  • targeted the correct branch (see PR Targeting)

  • provided a link to the relevant issue or specification

  • reviewed "Files changed" and left comments if necessary

  • included the necessary unit and integration tests

  • added a changelog entry to CHANGELOG.md

  • updated the relevant documentation or specification, including comments for documenting Go code

  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

Please see Pull Request Reviewer section in the contributing guide for more information on how to review a pull request.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic, API design and naming, documentation is accurate, tests and test coverage

Summary by CodeRabbit

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced a benchmarking module for the Cosmos SDK, allowing performance evaluation of blockchain nodes.
    • Added support for load testing with configurable parameters for transaction operations.
    • Implemented a generator for creating benchmark data, including statistical parameters for keys and values.
    • Added new Protocol Buffers definitions for benchmark operations and messages.
    • Introduced a command-line interface for executing load tests.
  • Improvements

    • Enhanced application configuration for better integration of the benchmarking module.
    • Updated telemetry settings for improved data retention and monitoring.
  • Documentation

    • Added README and CHANGELOG files for the benchmark module, outlining usage and version history.
  • Tests

    • Introduced unit tests for the generator module to ensure functionality and data integrity.
  • Chores

    • Updated dependency management files to include the new benchmark module.
    • Configured GitHub Actions for automated testing of the benchmark tools.
    • Added SonarQube configuration for project analysis.
    • Updated workflow for dependency management and automated updates.

This is an automatic backport of pull request #22778 done by [Mergify](https://mergify.com).

(cherry picked from commit 14c841c)

# Conflicts:
#	.github/dependabot.yml
#	go.work.example
#	simapp/app.go
#	simapp/go.mod
#	simapp/simd/cmd/testnet.go
#	simapp/v2/go.mod
#	tests/go.mod
@mergify mergify bot requested a review from a team as a code owner December 12, 2024 15:45
@mergify mergify bot added the conflicts label Dec 12, 2024
Copy link
Contributor Author

mergify bot commented Dec 12, 2024

Cherry-pick of 14c841c has failed:

On branch mergify/bp/release/v0.52.x/pr-22778
Your branch is up to date with 'origin/release/v0.52.x'.

You are currently cherry-picking commit 14c841c86.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   .github/pr_labeler.yml
	modified:   .github/workflows/test.yml
	new file:   api/cosmos/benchmark/module/v1/module.pulsar.go
	new file:   api/cosmos/benchmark/v1/benchmark.pulsar.go
	new file:   api/cosmos/benchmark/v1/tx.pulsar.go
	new file:   api/cosmos/benchmark/v1/tx_grpc.pb.go
	modified:   runtime/module.go
	modified:   scripts/build/build.mk
	modified:   scripts/init-simapp-v2.sh
	modified:   server/v2/cometbft/grpc.go
	modified:   simapp/app_config.go
	modified:   simapp/app_test.go
	new file:   simapp/benchmark.go
	modified:   simapp/v2/app_config.go
	modified:   simapp/v2/app_di.go
	new file:   simapp/v2/benchmark.go
	new file:   tools/benchmark/CHANGELOG.md
	new file:   tools/benchmark/README.md
	new file:   tools/benchmark/benchmark.pb.go
	new file:   tools/benchmark/client/cli/tx.go
	new file:   tools/benchmark/generator/gen.go
	new file:   tools/benchmark/generator/gen_test.go
	new file:   tools/benchmark/go.mod
	new file:   tools/benchmark/go.sum
	new file:   tools/benchmark/module/depinject.go
	new file:   tools/benchmark/module/keeper.go
	new file:   tools/benchmark/module/module.go
	new file:   tools/benchmark/proto/buf.gen.gogo.yaml
	new file:   tools/benchmark/proto/buf.gen.pulsar.yaml
	new file:   tools/benchmark/proto/buf.lock
	new file:   tools/benchmark/proto/buf.yaml
	new file:   tools/benchmark/proto/cosmos/benchmark/module/v1/module.proto
	new file:   tools/benchmark/proto/cosmos/benchmark/v1/benchmark.proto
	new file:   tools/benchmark/proto/cosmos/benchmark/v1/tx.proto
	new file:   tools/benchmark/sonar-project.properties
	new file:   tools/benchmark/tx.pb.go

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   .github/dependabot.yml
	both modified:   go.work.example
	both modified:   simapp/app.go
	both modified:   simapp/go.mod
	both modified:   simapp/simd/cmd/testnet.go
	both modified:   simapp/v2/go.mod
	both modified:   tests/go.mod

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

Copy link
Contributor

coderabbitai bot commented Dec 12, 2024

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

🪧 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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 generate docstrings to generate docstrings for this PR. (Experiment)
  • @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.

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.

cmd.Printf(
"success_tx=%d err_tx=%d seq=%d rate=%.2f/s overall=%.2f/s\n",
successCount, errCount, accSeq,
float64(successCount-last)/time.Since(since).Seconds(),

Check notice

Code scanning / CodeQL

Floating point arithmetic Note test

Floating point arithmetic operations are not associative and a possible source of non-determinism
"success_tx=%d err_tx=%d seq=%d rate=%.2f/s overall=%.2f/s\n",
successCount, errCount, accSeq,
float64(successCount-last)/time.Since(since).Seconds(),
float64(successCount)/time.Since(begin).Seconds(),

Check notice

Code scanning / CodeQL

Floating point arithmetic Note test

Floating point arithmetic operations are not associative and a possible source of non-determinism
// The operation is one of insert, update, get, or delete.
// The tx client calls this function to deterministically generate the next operation.
func (g *Generator) Next() (uint64, *benchmark.Op, error) {
if g.InsertWeight+g.UpdateWeight+g.GetWeight+g.DeleteWeight != 1 {

Check notice

Code scanning / CodeQL

Floating point arithmetic Note test

Floating point arithmetic operations are not associative and a possible source of non-determinism
// The operation is one of insert, update, get, or delete.
// The tx client calls this function to deterministically generate the next operation.
func (g *Generator) Next() (uint64, *benchmark.Op, error) {
if g.InsertWeight+g.UpdateWeight+g.GetWeight+g.DeleteWeight != 1 {

Check notice

Code scanning / CodeQL

Floating point arithmetic Note test

Floating point arithmetic operations are not associative and a possible source of non-determinism
// The operation is one of insert, update, get, or delete.
// The tx client calls this function to deterministically generate the next operation.
func (g *Generator) Next() (uint64, *benchmark.Op, error) {
if g.InsertWeight+g.UpdateWeight+g.GetWeight+g.DeleteWeight != 1 {

Check notice

Code scanning / CodeQL

Floating point arithmetic Note test

Floating point arithmetic operations are not associative and a possible source of non-determinism
op.Seed = key.Seed()
op.KeyLength = key.Length()
op.ValueLength = g.getLength(g.ValueMean, g.ValueStdDev)
case x < g.InsertWeight+g.UpdateWeight+g.GetWeight:

Check notice

Code scanning / CodeQL

Floating point arithmetic Note test

Floating point arithmetic operations are not associative and a possible source of non-determinism
op.Seed = key.Seed()
op.KeyLength = key.Length()
op.ValueLength = g.getLength(g.ValueMean, g.ValueStdDev)
case x < g.InsertWeight+g.UpdateWeight+g.GetWeight:

Check notice

Code scanning / CodeQL

Floating point arithmetic Note test

Floating point arithmetic operations are not associative and a possible source of non-determinism

// NormUint64 returns a random uint64 with a normal distribution.
func (g *Generator) NormUint64(mean, stdDev uint64) uint64 {
return uint64(g.rand.NormFloat64()*float64(stdDev) + float64(mean))

Check notice

Code scanning / CodeQL

Floating point arithmetic Note test

Floating point arithmetic operations are not associative and a possible source of non-determinism

// NormUint64 returns a random uint64 with a normal distribution.
func (g *Generator) NormUint64(mean, stdDev uint64) uint64 {
return uint64(g.rand.NormFloat64()*float64(stdDev) + float64(mean))

Check notice

Code scanning / CodeQL

Floating point arithmetic Note test

Floating point arithmetic operations are not associative and a possible source of non-determinism
package module

import (
"unsafe"

Check notice

Code scanning / CodeQL

Sensitive package import Note test

Certain system packages contain functions which may be a possible source of non-determinism
@julienrbrt julienrbrt merged commit 1fbc003 into release/v0.52.x Dec 13, 2024
71 of 73 checks passed
@julienrbrt julienrbrt deleted the mergify/bp/release/v0.52.x/pr-22778 branch December 13, 2024 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants