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

chore: ABCI methods benchmarks #3904

Merged
merged 37 commits into from
Oct 21, 2024
Merged

chore: ABCI methods benchmarks #3904

merged 37 commits into from
Oct 21, 2024

Conversation

rach-id
Copy link
Member

@rach-id rach-id commented Sep 25, 2024

Works on this: #3898

To run the benchmarks, run the following in the root directory:

go test -bench=<benchmark_name> app/benchmark_test.go

with <benchmark_name> is:

  • BenchmarkCheckTx_MsgSend_1: for a benchmark of a MsgSend transaction in CheckTx
  • BenchmarkCheckTx_MsgSend_8MB: for a benchmark of 8mb block worth of MsgSend transactions in CheckTx
  • BenchmarkDeliverTx_MsgSend_1: for a benchmark of a MsgSend transaction in DeliverTx
  • BenchmarkDeliverTx_MsgSend_8MB: for a benchmark of 8mb block worth of MsgSend transactions in DeliverTx
  • BenchmarkPrepareProposal_MsgSend_1: for a benchmark of a block containing a singleMsgSend transaction in PrepareProposal
  • BenchmarkPrepareProposal_MsgSend_8MB: for a benchmark of an 8mb block containing MsgSend transactions in PrepareProposal
  • BenchmarkProcessProposal_MsgSend_1: for a benchmark of a block containing a singleMsgSend transaction in ProcessProposal
  • BenchmarkProcessProposal_MsgSend_8MB: for a benchmark of an 8mb block containingMsgSend transactions in ProcessProposal
  • ...

Note: keeping this as a draft because it doesn't necessarily need to be merged

Benchmark run on: Macbook pro M3 max 48GB RAM

@rach-id rach-id requested a review from a team as a code owner September 25, 2024 06:27
@rach-id rach-id requested review from cmwaters and evan-forbes and removed request for a team September 25, 2024 06:27
@rach-id rach-id marked this pull request as draft September 25, 2024 06:27
Copy link
Contributor

coderabbitai bot commented Sep 25, 2024

Note

Reviews paused

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.
📝 Walkthrough
📝 Walkthrough

Walkthrough

This pull request introduces a suite of benchmark tests for transaction processing functionalities in the Celestia application, focusing on MsgSend, IBC client updates, and "Pay For Blob" transactions. It updates constants related to transaction limits and modifies the test application initialization for improved timestamp accuracy. New utility functions for transaction generation and performance metrics calculation are also added.

Changes

Files Change Summary
app/benchmarks/benchmark_ibc_update_client_test.go, app/benchmarks/benchmark_msg_send_test.go, app/benchmarks/benchmark_pfb_test.go Added benchmark tests for IBC client updates, MsgSend transactions, and PFB transactions, including various performance measurement functions and utility functions for transaction generation and metrics calculation.
pkg/appconsts/initial_consts.go, pkg/appconsts/global_consts.go, pkg/appconsts/prepare_proposal_consts.go, pkg/appconsts/prepare_proposal_consts_bench.go Updated DefaultGovMaxSquareSize, removed old transaction cap constants, and introduced new transaction cap constants with specified limits. Added a benchmarking file for transaction caps.
test/util/test_app.go Enhanced initialization of the test application, restructuring GenesisTime, adding a logger, and improving the dynamic assignment of block header timestamps.

Possibly related PRs

Suggested labels

testing, enhancement, WS: Big Blonks 🔭

Suggested reviewers

  • evan-forbes
  • staheri14
  • ninabarbakadze
  • cmwaters

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:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • 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 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.

@celestia-bot celestia-bot requested a review from a team September 25, 2024 06:27
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: 6

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between af38e41 and 91b40ae.

📒 Files selected for processing (3)
  • app/benchmark_test.go (1 hunks)
  • pkg/appconsts/initial_consts.go (1 hunks)
  • test/util/test_app.go (1 hunks)
🔇 Additional comments not posted (2)
pkg/appconsts/initial_consts.go (1)

14-14: Verify the implications of doubling DefaultGovMaxSquareSize.

The DefaultGovMaxSquareSize has been increased from 64 to 128, which effectively quadruples the DefaultMaxBytes (since it's calculated as the square of DefaultGovMaxSquareSize). This significant increase may have substantial impacts on network performance and resource requirements.

Consider the following:

  1. Does this change align with the PR objectives of adding benchmarks for 8MB message sending?
  2. Have performance tests been conducted to ensure the network can handle this increased load?
  3. Are there any downstream effects on other parts of the system that rely on these constants?

To assess the impact, let's check for usages of this constant and related calculations:

Consider adding comments explaining the rationale behind this change and any performance considerations. This will help future maintainers understand the decision-making process.

test/util/test_app.go (1)

191-191: Ensure this change aligns with benchmark requirements

The modification to use cparams.Block.MaxBytes instead of a constant value for MaxBytes allows for more flexible configuration of the maximum block size in test environments. This change seems to align with the PR objective of adding benchmarks for various block sizes, including 8MB blocks.

However, please verify the following:

  1. Confirm that this change doesn't affect existing tests that may rely on the previous constant value.
  2. Ensure that the cparams passed to this function in the new benchmark tests are correctly set to achieve the desired block sizes (e.g., 8MB for the 8MB benchmarks).
  3. Consider adding a comment explaining the reason for this change to improve code maintainability.

To ensure this change doesn't introduce unintended side effects, let's check its usage:

✅ Verification successful

Change to use cparams.Block.MaxBytes is correctly propagated

The modification to set MaxBytes using cparams.Block.MaxBytes in test/util/test_app.go has been verified across the codebase. All relevant tests correctly configure cparams.Block.MaxBytes, ensuring that the change aligns with the PR objectives and does not introduce unintended side effects.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for all occurrences of NewTestAppWithGenesisSet to verify if any existing tests might be affected
rg --type go "NewTestAppWithGenesisSet" --glob '!test/util/test_app.go'

# Search for new benchmark tests that use this function to confirm proper usage
rg --type go "NewTestAppWithGenesisSet.*cparams" app/benchmark_test.go

Length of output: 357


Script:

#!/bin/bash
# Inspect the configuration of cparams.Block.MaxBytes in grpc_query_test.go
rg "cparams\.Block\.MaxBytes" x/minfee/grpc_query_test.go

# Inspect the configuration of cparams.Block.MaxBytes in tx_size_test.go
rg "cparams\.Block\.MaxBytes" app/ante/tx_size_test.go

Length of output: 116


Script:

#!/bin/bash
# Search for all occurrences of cparams.Block.MaxBytes in the codebase
rg --type go "cparams\.Block\.MaxBytes"

Length of output: 408

app/benchmark_test.go Outdated Show resolved Hide resolved
app/benchmark_test.go Outdated Show resolved Hide resolved
app/benchmark_test.go Outdated Show resolved Hide resolved
app/benchmark_test.go Outdated Show resolved Hide resolved
app/benchmark_test.go Outdated Show resolved Hide resolved
app/benchmark_test.go Outdated Show resolved Hide resolved
@rach-id
Copy link
Member Author

rach-id commented Sep 25, 2024

First results:

  • BenchmarkCheckTx_MsgSend:
5904            169616 ns/op
  • BenchmarkDeliverTx_MsgSend:
22509             53807 ns/op
  • BenchmarkPrepareProposal_MsgSend_1:
4668            222538 ns/op
  • BenchmarkPrepareProposal_MsgSend_8MB:
I[2024-09-25|10:31:46.555] block prepared                               numberoftransactions=31645 blocksize(mb)~=7.408

BenchmarkPrepareProposal_MsgSend_8MB-16                1        6109720625 ns/op

which contains 31645 msg send transactions in a block totalling 7.4mb

  • BenchmarkProcessProposal_MsgSend_1:
4855            215620 ns/op
  • BenchmarkProcessProposal_MsgSend_8MB:
I[2024-09-25|10:34:39.983] block prepared                               numberoftransactions=31645 blocksize(mb)~=7.408

BenchmarkProcessProposal_MsgSend_8MB-16                1        4891330792 ns/op

which contains 31645 msg send transactions in a block totalling 7.4mb

cc @cmwaters

@rach-id
Copy link
Member Author

rach-id commented Sep 25, 2024

Concerning the second part of the issue which requires testing the update client transaction. Does it make sense to instead test a multisig send transaction and have the same number of signatures (150 for example). This would be the same cost if we just want to check how costly it is to verify the signatures.

cc @cmwaters @evan-forbes

@cmwaters
Copy link
Contributor

Is this just because it's far simpler to do that than create the IBC headers? I think a multi sig can only have at most 7 transactions

@cmwaters
Copy link
Contributor

Am I reading this correctly that it takes 6 seconds for prepare proposal and almost 5 seconds for process proposal? (at 8MB of SendMsgs)

That's quite a bit.

Can you also measure how long it takes to have 8MB worth of send msgs via DeliverTx - or can I just go 31645 * 53807 ns/op?

Do you know why CheckTx takes more than 3 times longer than DeliverTx?

And then finally it would be good to compare this with 8MB worth of blob transactions that are each 4KB in size (number picked at random - I actually don't know what the average PFB size is).

@rach-id
Copy link
Member Author

rach-id commented Sep 26, 2024

Am I reading this correctly that it takes 6 seconds for prepare proposal and almost 5 seconds for process proposal? (at 8MB of SendMsgs)

yes.

Can you also measure how long it takes to have 8MB worth of send msgs via DeliverTx - or can I just go 31645 * 53807 ns/op?

  • Added bench of 8mb worth of msg send for CheckTx in BenchmarkCheckTx_MsgSend_8MB and results are:
BenchmarkCheckTx_MsgSend_8MB-16    	       1	6674640667 ns/op
  • Also, for DeliverTx, with same number of transactions in BenchmarkDeliverTx_MsgSend_8MB:
BenchmarkDeliverTx_MsgSend_8MB-16    	       1	2114091208 ns/op

Will work on the points and get you the results.

@cmwaters
Copy link
Contributor

Ok so that seems like a significant amount of time given we want blocks to be sub 6 seconds.

If we're going to limit the gas in a block can you also work out the total gas of those two respective blocks I.e. (all MsgSend and all 4KB PFBs) 🙏

@rach-id
Copy link
Member Author

rach-id commented Sep 27, 2024

For the PFBs, I added the following benchmarks: BenchmarkPrepareProposal_PFB_Multi which benchmarks prepare proposal with blocks with different blob sizes. The results are:

15000_transactions_of_300_bytes-16         	       1	2501182208 ns/op	         6.239 block_size(mb)	     10318 number_of_transactions	2501182208 prepare_proposal_time(ns)	988490895000 total_gas_used	       703.0 transactions_size(byte)

10000_transactions_of_500_bytes-16         	       1	1689812542 ns/op	         5.035 block_size(mb)	      6331 number_of_transactions	1689812542 prepare_proposal_time(ns)	439343930000 total_gas_used	       903.0 transactions_size(byte)

6000_transactions_of_1000_bytes-16         	       1	1036703375 ns/op	         5.809 block_size(mb)	      4566 number_of_transactions	1036703375 prepare_proposal_time(ns)	158174358000 total_gas_used	      1403 transactions_size(byte)

3000_transactions_of_5000_bytes-16         	1000000000	         0.5361 ns/op	         7.188 block_size(mb)	      1413 number_of_transactions	 536124042 prepare_proposal_time(ns)	39550179000 total_gas_used	      5403 transactions_size(byte)

1000_transactions_of_10000_bytes-16        	1000000000	         0.2098 ns/op	         7.470 block_size(mb)	       758.0 number_of_transactions	 209832875 prepare_proposal_time(ns)	4397393000 total_gas_used	     10403 transactions_size(byte)

500_transactions_of_50000_bytes-16         	1000000000	         0.1262 ns/op	         7.441 block_size(mb)	       155.0 number_of_transactions	 126233584 prepare_proposal_time(ns)	1100446500 total_gas_used	     50406 transactions_size(byte)

100_transactions_of_100000_bytes-16        	1000000000	         0.05864 ns/op	         7.368 block_size(mb)	        77.00 number_of_transactions	  58644708 prepare_proposal_time(ns)	  44369300 total_gas_used	    100406 transactions_size(byte)

100_transactions_of_200000_bytes-16        	1000000000	         0.06557 ns/op	         7.260 block_size(mb)	        38.00 number_of_transactions	  65569750 prepare_proposal_time(ns)	  44369300 total_gas_used	    200406 transactions_size(byte)

50_transactions_of_300000_bytes-16         	1000000000	         0.05194 ns/op	         7.161 block_size(mb)	        25.00 number_of_transactions	  51936375 prepare_proposal_time(ns)	  11202150 total_gas_used	    300406 transactions_size(byte)

50_transactions_of_400000_bytes-16         	1000000000	         0.04908 ns/op	         7.254 block_size(mb)	        19.00 number_of_transactions	  49077375 prepare_proposal_time(ns)	  11202150 total_gas_used	    400406 transactions_size(byte)

30_transactions_of_500000_bytes-16         	1000000000	         0.05085 ns/op	         7.157 block_size(mb)	        15.00 number_of_transactions	  50846708 prepare_proposal_time(ns)	   4085490 total_gas_used	    500406 transactions_size(byte)

10_transactions_of_1000000_bytes-16        	1000000000	         0.03060 ns/op	         6.678 block_size(mb)	         7.000 number_of_transactions	  30597791 prepare_proposal_time(ns)	    483230 total_gas_used	   1000406 transactions_size(byte)

5_transactions_of_2000000_bytes-16         	1000000000	         0.02862 ns/op	         5.723 block_size(mb)	         3.000 number_of_transactions	  28619250 prepare_proposal_time(ns)	    131790 total_gas_used	   2000406 transactions_size(byte)

3_transactions_of_3000000_bytes-16         	1000000000	         0.04402 ns/op	         5.723 block_size(mb)	         2.000 number_of_transactions	  44022417 prepare_proposal_time(ns)	     52716 total_gas_used	   3000409 transactions_size(byte)

3_transactions_of_4000000_bytes-16         	1000000000	         0.03565 ns/op	         3.815 block_size(mb)	         1.000 number_of_transactions	  35649792 prepare_proposal_time(ns)	     52716 total_gas_used	   4000409 transactions_size(byte)

2_transactions_of_5000000_bytes-16         	1000000000	         0.03975 ns/op	         4.769 block_size(mb)	         1.000 number_of_transactions	  39753500 prepare_proposal_time(ns)	     26358 total_gas_used	   5000409 transactions_size(byte)

2_transactions_of_6000000_bytes-16         	1000000000	         0.03288 ns/op	         5.722 block_size(mb)	         1.000 number_of_transactions	  32875500 prepare_proposal_time(ns)	     26358 total_gas_used	   6000409 transactions_size(byte)

cc @evan-forbes @cmwaters

@rach-id
Copy link
Member Author

rach-id commented Sep 27, 2024

Same for process proposal, I added BenchmarkProcessProposal_PFB_Multi which benchmarks process proposal using different blob sizes. The results:

15000_transactions_of_300_bytes-16         	       1	1689482458 ns/op	         6.239 block_size(mb)	     10318 number_of_transactions	1689482458 process_proposal_time(ns)	988490895000 total_gas_used	       703.0 transactions_size(byte)

10000_transactions_of_500_bytes-16         	       1	1079362750 ns/op	         5.035 block_size(mb)	      6331 number_of_transactions	1079362750 process_proposal_time(ns)	439343930000 total_gas_used	       903.0 transactions_size(byte)

6000_transactions_of_1000_bytes-16         	1000000000	         0.8345 ns/op	         5.809 block_size(mb)	      4566 number_of_transactions	 834506584 process_proposal_time(ns)	158174358000 total_gas_used	      1403 transactions_size(byte)

3000_transactions_of_5000_bytes-16         	1000000000	         0.2946 ns/op	         7.188 block_size(mb)	      1413 number_of_transactions	 294579000 process_proposal_time(ns)	39550179000 total_gas_used	      5403 transactions_size(byte)

1000_transactions_of_10000_bytes-16        	1000000000	         0.1982 ns/op	         7.470 block_size(mb)	       758.0 number_of_transactions	 198208000 process_proposal_time(ns)	4397393000 total_gas_used	     10403 transactions_size(byte)

500_transactions_of_50000_bytes-16         	1000000000	         0.08576 ns/op	         7.441 block_size(mb)	       155.0 number_of_transactions	  85762584 process_proposal_time(ns)	1100446500 total_gas_used	     50406 transactions_size(byte)

100_transactions_of_100000_bytes-16        	1000000000	         0.06285 ns/op	         7.368 block_size(mb)	        77.00 number_of_transactions	  62845333 process_proposal_time(ns)	  44369300 total_gas_used	    100406 transactions_size(byte)

100_transactions_of_200000_bytes-16        	1000000000	         0.06041 ns/op	         7.260 block_size(mb)	        38.00 number_of_transactions	  60412833 process_proposal_time(ns)	  44369300 total_gas_used	    200406 transactions_size(byte)

50_transactions_of_300000_bytes-16         	1000000000	         0.05762 ns/op	         7.161 block_size(mb)	        25.00 number_of_transactions	  57616250 process_proposal_time(ns)	  11202150 total_gas_used	    300406 transactions_size(byte)

50_transactions_of_400000_bytes-16         	1000000000	         0.05062 ns/op	         7.254 block_size(mb)	        19.00 number_of_transactions	  50619375 process_proposal_time(ns)	  11202150 total_gas_used	    400406 transactions_size(byte)

30_transactions_of_500000_bytes-16         	1000000000	         0.06729 ns/op	         7.157 block_size(mb)	        15.00 number_of_transactions	  67294042 process_proposal_time(ns)	   4085490 total_gas_used	    500406 transactions_size(byte)

10_transactions_of_1000000_bytes-16        	1000000000	         0.04874 ns/op	         6.678 block_size(mb)	         7.000 number_of_transactions	  48740916 process_proposal_time(ns)	    483230 total_gas_used	   1000406 transactions_size(byte)

5_transactions_of_2000000_bytes-16         	1000000000	         0.05007 ns/op	         5.723 block_size(mb)	         3.000 number_of_transactions	  50073333 process_proposal_time(ns)	    131790 total_gas_used	   2000406 transactions_size(byte)

3_transactions_of_3000000_bytes-16         	1000000000	         0.04831 ns/op	         5.723 block_size(mb)	         2.000 number_of_transactions	  48314167 process_proposal_time(ns)	     52716 total_gas_used	   3000409 transactions_size(byte)

3_transactions_of_4000000_bytes-16         	1000000000	         0.06277 ns/op	         3.815 block_size(mb)	         1.000 number_of_transactions	  62765083 process_proposal_time(ns)	     52716 total_gas_used	   4000409 transactions_size(byte)

2_transactions_of_5000000_bytes-16         	1000000000	         0.03646 ns/op	         4.769 block_size(mb)	         1.000 number_of_transactions	  36457375 process_proposal_time(ns)	     26358 total_gas_used	   5000409 transactions_size(byte)

2_transactions_of_6000000_bytes-16         	1000000000	         0.04704 ns/op	         5.722 block_size(mb)	         1.000 number_of_transactions	  47042125 process_proposal_time(ns)	     26358 total_gas_used	   6000409 transactions_size(byte)

cc @evan-forbes @cmwaters

@rach-id
Copy link
Member Author

rach-id commented Sep 27, 2024

Same for check tx, I added BenchmarkCheckTx_PFB_Multi which benchmarks check tx using different blob sizes. The results:

300_bytes-16         	    6654	    175511 ns/op	     61356 gas_used	       703.0 transaction_size(byte)

500_bytes-16         	    6379	    179029 ns/op	     61356 gas_used	       903.0 transaction_size(byte)

1000_bytes-16        	    6408	    181527 ns/op	     61356 gas_used	      1403 transaction_size(byte)

5000_bytes-16        	    5929	    201542 ns/op	     61356 gas_used	      5403 transaction_size(byte)

10000_bytes-16       	    5359	    228696 ns/op	     61356 gas_used	     10403 transaction_size(byte)

50000_bytes-16       	    3518	    332609 ns/op	     61366 gas_used	     50406 transaction_size(byte)

100000_bytes-16      	    2605	    446551 ns/op	     61366 gas_used	    100406 transaction_size(byte)

200000_bytes-16      	    1786	    666961 ns/op	     61366 gas_used	    200406 transaction_size(byte)

300000_bytes-16      	    1372	    866706 ns/op	     61366 gas_used	    300406 transaction_size(byte)

400000_bytes-16      	    1076	   1093213 ns/op	     61366 gas_used	    400406 transaction_size(byte)

500000_bytes-16      	     922	   1289988 ns/op	     61366 gas_used	    500406 transaction_size(byte)

1000000_bytes-16     	     514	   2329951 ns/op	     61366 gas_used	   1000406 transaction_size(byte)

2000000_bytes-16     	     270	   4477223 ns/op	     61366 gas_used	   2000406 transaction_size(byte)

3000000_bytes-16     	     184	   6467632 ns/op	     61376 gas_used	   3000409 transaction_size(byte)

4000000_bytes-16     	     140	   8446076 ns/op	     61376 gas_used	   4000409 transaction_size(byte)

5000000_bytes-16     	     100	  10610712 ns/op	     61376 gas_used	   5000409 transaction_size(byte)

6000000_bytes-16     	      88	  12589757 ns/op	     61376 gas_used	   6000409 transaction_size(byte)

@rach-id
Copy link
Member Author

rach-id commented Sep 27, 2024

Same for deliver tx, I added BenchmarkDeliverTx_PFB_Multi which benchmarks deliver tx using different blob sizes. The results:

300_bytes-16         	  126498	      8503 ns/op	1111474019 gas_used	       703.0 transaction_size(byte)

500_bytes-16         	  122810	      9178 ns/op	1079071251 gas_used	       903.0 transaction_size(byte)

1000_bytes-16        	  118024	      9850 ns/op	1037021455 gas_used	      1403 transaction_size(byte)

5000_bytes-16        	  101962	     14902 ns/op	 895900723 gas_used	      5403 transaction_size(byte)

10000_bytes-16       	   75381	     16963 ns/op	 662360057 gas_used	     10403 transaction_size(byte)

50000_bytes-16       	   36753	     30369 ns/op	 322974449 gas_used	     50406 transaction_size(byte)

100000_bytes-16      	   23551	     50086 ns/op	 206981677 gas_used	    100406 transaction_size(byte)

200000_bytes-16      	   13953	     89059 ns/op	 122653649 gas_used	    200406 transaction_size(byte)

300000_bytes-16      	    8750	    127090 ns/op	  76940091 gas_used	    300406 transaction_size(byte)

400000_bytes-16      	    7314	    156464 ns/op	  64323395 gas_used	    400406 transaction_size(byte)

500000_bytes-16      	    6310	    192877 ns/op	  55502251 gas_used	    500406 transaction_size(byte)

1000000_bytes-16     	    3226	    362805 ns/op	  28406227 gas_used	   1000406 transaction_size(byte)

2000000_bytes-16     	    1641	    705051 ns/op	  14480417 gas_used	   2000406 transaction_size(byte)

3000000_bytes-16     	    1129	   1030048 ns/op	   9981985 gas_used	   3000409 transaction_size(byte)

4000000_bytes-16     	     880	   1381749 ns/op	   7794271 gas_used	   4000409 transaction_size(byte)

5000000_bytes-16     	     696	   1733789 ns/op	   6177647 gas_used	   5000409 transaction_size(byte)

6000000_bytes-16     	     548	   2072252 ns/op	   4877319 gas_used	   6000409 transaction_size(byte)

@rach-id
Copy link
Member Author

rach-id commented Sep 27, 2024

I will working on the remaining benchmarks and share the results once I have them

@rach-id
Copy link
Member Author

rach-id commented Sep 27, 2024

If we're going to limit the gas in a block can you also work out the total gas of those two respective blocks I.e. (all MsgSend and all 4KB PFBs) 🙏

For an 8mb block full of msg send:

BenchmarkPrepareProposal_MsgSend_8MB-16    	       1	6119119000 ns/op	         7.408 block_size(mb)	     31645 number_of_transactions	2288906265 total_gas_used

For the PFBs, the total gas is in the previous comments.

@rach-id
Copy link
Member Author

rach-id commented Sep 27, 2024

Can you also measure how long it takes to have 8MB worth of send msgs via DeliverTx - or can I just go 31645 * 53807 ns/op?

BenchmarkDeliverTx_MsgSend_8MB-16    	       1	2430262231 ns/op	1892513374 total_gas_used

@rach-id
Copy link
Member Author

rach-id commented Sep 30, 2024

IBC update clientcheckTx benchmark with multiple signatures number in BenchmarkIBC_CheckTx_Update_Client_Multi:

number_of_validators:_2-16         	   16861	     72076 ns/op	     57713 gas_used	         2.000 number_of_validators	         1.000 number_of_verified_signatures	      1399 transaction_size(byte)

number_of_validators:_10-16        	   12540	     92223 ns/op	     76753 gas_used	        10.00 number_of_validators	         6.000 number_of_verified_signatures	      3303 transaction_size(byte)

number_of_validators:_25-16        	    9147	    126315 ns/op	    112473 gas_used	        25.00 number_of_validators	        16.00 number_of_verified_signatures	      6875 transaction_size(byte)

number_of_validators:_50-16        	    6448	    181547 ns/op	    171973 gas_used	        50.00 number_of_validators	        33.00 number_of_verified_signatures	     12825 transaction_size(byte)

number_of_validators:_75-16        	    4620	    236575 ns/op	    231523 gas_used	        75.00 number_of_validators	        50.00 number_of_verified_signatures	     18780 transaction_size(byte)

number_of_validators:_100-16       	    3576	    283364 ns/op	    291023 gas_used	       100.0 number_of_validators	        66.00 number_of_verified_signatures	     24730 transaction_size(byte)

number_of_validators:_125-16       	    3607	    333925 ns/op	    350523 gas_used	       125.0 number_of_validators	        83.00 number_of_verified_signatures	     30680 transaction_size(byte)

number_of_validators:_150-16       	    3114	    402968 ns/op	    410023 gas_used	       150.0 number_of_validators	       100.0 number_of_verified_signatures	     36630 transaction_size(byte)

number_of_validators:_175-16       	    2588	    433434 ns/op	    467783 gas_used	       175.0 number_of_validators	       116.0 number_of_verified_signatures	     42406 transaction_size(byte)

number_of_validators:_200-16       	    2174	    477910 ns/op	    529043 gas_used	       200.0 number_of_validators	       133.0 number_of_verified_signatures	     48532 transaction_size(byte)

number_of_validators:_225-16       	    2280	    527478 ns/op	    588543 gas_used	       225.0 number_of_validators	       150.0 number_of_verified_signatures	     54482 transaction_size(byte)

number_of_validators:_250-16       	    1994	    577420 ns/op	    648063 gas_used	       250.0 number_of_validators	       166.0 number_of_verified_signatures	     60434 transaction_size(byte)

number_of_validators:_300-16       	    1794	    700452 ns/op	    764053 gas_used	       300.0 number_of_validators	       200.0 number_of_verified_signatures	     72033 transaction_size(byte)

number_of_validators:_400-16       	    1350	    873867 ns/op	   1005063 gas_used	       400.0 number_of_validators	       266.0 number_of_verified_signatures	     96134 transaction_size(byte)

number_of_validators:_500-16       	    1023	   1080929 ns/op	   1243063 gas_used	       500.0 number_of_validators	       333.0 number_of_verified_signatures	    119934 transaction_size(byte)

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: 4

🧹 Outside diff range and nitpick comments (4)
pkg/appconsts/prepare_proposal_consts_bench.go (2)

5-6: LGTM: Clear and informative comment.

The comment effectively explains the purpose of these constants and directs users to the production values. This helps prevent misuse of these benchmark-specific constants.

Consider adding the full path to the prepare_proposal_consts.go file for easier reference:

- // For the production values, check prepare_proposal_consts.go file.
+ // For the production values, check pkg/appconsts/prepare_proposal_consts.go file.

8-14: LGTM: Constants are well-defined for benchmarking purposes.

The constants NonPFBTransactionCap and PFBTransactionCap are clearly named and set to appropriately high values for benchmarking. The comments provide good context.

Consider using a named constant for the value to improve maintainability:

+ const benchmarkMaxValue = 999999999999

  const (
- 	NonPFBTransactionCap = 999999999999
+ 	NonPFBTransactionCap = benchmarkMaxValue

- 	PFBTransactionCap = 999999999999
+ 	PFBTransactionCap = benchmarkMaxValue
  )

This change would make it easier to update the value in the future if needed.

app/benchmarks/README.md (2)

9-15: LGTM: Clear instructions for running benchmarks.

The instructions are concise and easy to follow. The use of a code block for the shell command enhances readability.

Consider adding a brief explanation of how to replace <benchmark_name> with specific benchmark names or provide a few examples. This would make it easier for users to run specific benchmarks without referring to other documentation.


21-27: LGTM: Informative key takeaways with a minor grammatical suggestion.

The key takeaways section effectively summarizes important decisions and findings from the benchmarks. The explanation of transaction caps and their impact on block construction is clear and informative.

On line 27, consider adding the article "a" before "16 core 48GM RAM machine" for improved grammar:

-As specified in [results](results.md) documents, those results were generated on 16 core 48GM RAM machine, and gave us certain thresholds.
+As specified in [results](results.md) documents, those results were generated on a 16 core 48GM RAM machine, and gave us certain thresholds.
🧰 Tools
🪛 LanguageTool

[uncategorized] ~27-~27: You might be missing the article “a” here.
Context: ...uments, those results were generated on 16 core 48GM RAM machine, and gave us cert...

(AI_EN_LECTOR_MISSING_DETERMINER_A)

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between ce56501 and 2bd31ca.

📒 Files selected for processing (6)
  • app/benchmarks/README.md (1 hunks)
  • app/benchmarks/benchmark_ibc_update_client_test.go (1 hunks)
  • app/benchmarks/benchmark_msg_send_test.go (1 hunks)
  • app/benchmarks/benchmark_pfb_test.go (1 hunks)
  • pkg/appconsts/prepare_proposal_consts.go (1 hunks)
  • pkg/appconsts/prepare_proposal_consts_bench.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • app/benchmarks/benchmark_msg_send_test.go
  • pkg/appconsts/prepare_proposal_consts.go
🧰 Additional context used
🪛 LanguageTool
app/benchmarks/README.md

[uncategorized] ~27-~27: You might be missing the article “a” here.
Context: ...uments, those results were generated on 16 core 48GM RAM machine, and gave us cert...

(AI_EN_LECTOR_MISSING_DETERMINER_A)

🔇 Additional comments (4)
pkg/appconsts/prepare_proposal_consts_bench.go (2)

1-3: LGTM: Build constraint and package declaration are appropriate.

The build constraint //go:build bench_abci_methods ensures this file is only used for benchmarking, which is a good practice for separating benchmark-specific code. The package name appconsts is suitable for application constants.


1-14: Overall, the file is well-structured and fit for purpose.

This new file prepare_proposal_consts_bench.go is appropriately designed for benchmarking ABCI methods. It uses a build constraint to ensure it's only compiled for benchmarks, provides clear constants with high values suitable for testing, and includes informative comments. The suggested minor improvements (specifying the full path in the comment and using a named constant for the benchmark value) would further enhance its clarity and maintainability.

app/benchmarks/README.md (2)

1-7: LGTM: Clear introduction and comprehensive list of benchmarks.

The introduction effectively outlines the purpose of the package and provides a clear list of the transaction types being benchmarked.


17-19: LGTM: Appropriate reference to results document.

The reference to a separate results document is a good practice for maintaining detailed benchmark outcomes without cluttering the main README.

app/benchmarks/benchmark_pfb_test.go Show resolved Hide resolved
app/benchmarks/benchmark_pfb_test.go Show resolved Hide resolved
app/benchmarks/benchmark_ibc_update_client_test.go Outdated Show resolved Hide resolved
rootulp
rootulp previously approved these changes Oct 17, 2024
Copy link
Collaborator

@rootulp rootulp left a comment

Choose a reason for hiding this comment

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

Works on this: #3898

If this doesn't close #3898 then what is left on that issue? Seems like we can close it after this merges


## Key takeaways

We decided to softly limit the number of messages contained in a block, via introducing the `NonPFBTransactionCap` and `PFBTransactionCap`, and checking against them in prepare proposal.
Copy link
Collaborator

Choose a reason for hiding this comment

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

[optional] rename constants if the other PR merges

app/benchmarks/README.md Outdated Show resolved Hide resolved
app/benchmarks/benchmark_ibc_update_client_test.go Outdated Show resolved Hide resolved
app/benchmarks/benchmark_ibc_update_client_test.go Outdated Show resolved Hide resolved
app/benchmarks/benchmark_ibc_update_client_test.go Outdated Show resolved Hide resolved
app/benchmarks/benchmark_msg_send_test.go Outdated Show resolved Hide resolved
@@ -0,0 +1,839 @@
<!-- markdownlint-disable -->
Copy link
Collaborator

Choose a reason for hiding this comment

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

[question] why disable markdownlint for this file?

Copy link
Member Author

Choose a reason for hiding this comment

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

because it complains about redundant headings all over the document so I decided not to lint it

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: 17

🧹 Outside diff range and nitpick comments (3)
app/benchmarks/README.md (3)

9-16: Consider explaining the purpose of the tag.

The instructions for running the benchmarks are clear. However, it might be helpful to briefly explain the purpose of the -tags=bench_abci_methods flag for users who are unfamiliar with it.


17-19: Consider adding a brief summary of key results.

While referring to a separate document for detailed results is appropriate, it might be helpful to include a brief summary or highlight key findings in this README. This would give readers a quick overview without needing to navigate to another document.


21-27: Improve clarity and fix grammatical issues in the "Key takeaways" section.

The content provides valuable information, but consider the following improvements:

  1. Clarify the purpose of NonPFBTransactionCap and PFBTransactionCap. What do these caps represent?

  2. Address the grammatical issues:

    • Line 25: Add a comma after "consensus" for better readability.
    • Line 27: Consider rephrasing to "As specified in the results document, these results were generated on a 16-core, 48GB RAM machine, which gave us certain thresholds."
    • Line 27: Change "when we run" to "when we ran" for consistent past tense.
  3. Consider explaining why the lower numbers from the recommended validator setup were used for the limits. This would provide context for the decision-making process.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~25-~25: Possible missing comma found.
Context: ...hem reached consensus, it will still be accepted since this rule is not consensus breaki...

(AI_HYDRA_LEO_MISSING_COMMA)


[uncategorized] ~27-~27: You might be missing the article “a” here.
Context: ...cument, those results were generated on 16 core 48GB RAM machine, and gave us cert...

(AI_EN_LECTOR_MISSING_DETERMINER_A)


[uncategorized] ~27-~27: This verb may not be in the correct tense. Consider changing the tense to fit the context better.
Context: ...us certain thresholds. However, when we run the same experiments on the recommended...

(AI_EN_LECTOR_REPLACEMENT_VERB_TENSE)

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 2bd31ca and a76ffcc.

📒 Files selected for processing (4)
  • app/benchmarks/README.md (1 hunks)
  • app/benchmarks/benchmark_ibc_update_client_test.go (1 hunks)
  • app/benchmarks/benchmark_msg_send_test.go (1 hunks)
  • app/benchmarks/benchmark_pfb_test.go (1 hunks)
🧰 Additional context used
🪛 LanguageTool
app/benchmarks/README.md

[uncategorized] ~25-~25: Possible missing comma found.
Context: ...hem reached consensus, it will still be accepted since this rule is not consensus breaki...

(AI_HYDRA_LEO_MISSING_COMMA)


[uncategorized] ~27-~27: You might be missing the article “a” here.
Context: ...cument, those results were generated on 16 core 48GB RAM machine, and gave us cert...

(AI_EN_LECTOR_MISSING_DETERMINER_A)


[uncategorized] ~27-~27: This verb may not be in the correct tense. Consider changing the tense to fit the context better.
Context: ...us certain thresholds. However, when we run the same experiments on the recommended...

(AI_EN_LECTOR_REPLACEMENT_VERB_TENSE)

🔇 Additional comments (3)
app/benchmarks/README.md (1)

1-8: LGTM: Clear introduction and benchmark types.

The introduction effectively outlines the purpose of the package and clearly lists the types of transactions being benchmarked.

app/benchmarks/benchmark_msg_send_test.go (1)

1-23: LGTM: Appropriate build tag and imports for benchmark tests.

The build tag bench_abci_methods is correctly used to isolate these benchmarks. The imports cover all necessary packages for the benchmark tests, including Celestia app components, Cosmos SDK types, and Tendermint ABCI types.

app/benchmarks/benchmark_pfb_test.go (1)

156-177: Verify implementation of helper functions

The benchmark for PrepareProposal looks well-structured. However, it relies on two helper functions that are not visible in this file: calculateBlockSizeInMb and calculateTotalGasUsed. To ensure the accuracy of the reported metrics, we should verify the implementation of these functions.

Could you please provide the implementation of calculateBlockSizeInMb and calculateTotalGasUsed functions? This will help ensure that the metrics are being calculated correctly.

✅ Verification successful

Helper functions correctly implemented

The implementations of calculateBlockSizeInMb and calculateTotalGasUsed accurately perform their intended calculations, ensuring the benchmark metrics are reliable.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for the implementation of helper functions
rg -A 10 'func calculateBlockSizeInMb'
rg -A 10 'func calculateTotalGasUsed'

Length of output: 1377

app/benchmarks/benchmark_msg_send_test.go Show resolved Hide resolved
app/benchmarks/benchmark_msg_send_test.go Outdated Show resolved Hide resolved
app/benchmarks/benchmark_msg_send_test.go Show resolved Hide resolved
app/benchmarks/benchmark_msg_send_test.go Show resolved Hide resolved
app/benchmarks/benchmark_pfb_test.go Show resolved Hide resolved
app/benchmarks/benchmark_pfb_test.go Show resolved Hide resolved
app/benchmarks/benchmark_ibc_update_client_test.go Outdated Show resolved Hide resolved
@rach-id
Copy link
Member Author

rach-id commented Oct 18, 2024

@coderabbitai pause

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: 13

🧹 Outside diff range and nitpick comments (3)
app/benchmarks/benchmark_pfb_test.go (1)

1-381: Summary of improvement suggestions for the benchmark suite

  1. Utilize b.N for iterations in most benchmark functions to improve accuracy and stability of results.
  2. Generate unique blobs for each transaction in generatePayForBlobTransactions to better simulate real-world scenarios.
  3. Improve error handling in the binary search of benchmarkProcessProposalPFBHalfSecond to provide more context when maximum iterations are reached.

These changes will enhance the reliability and realism of the benchmark suite, providing more accurate performance measurements for the Celestia application's handling of Pay For Blob (PFB) transactions.

app/benchmarks/benchmark_ibc_update_client_test.go (2)

132-146: Consider adding comments to explain the test case values

The testCases array in BenchmarkIBC_PrepareProposal_Update_Client_Multi defines specific numberOfTransactions and numberOfValidators. Adding comments to explain the rationale behind these values and how they impact the benchmarks would enhance code readability and assist future maintainers in understanding the testing scenarios.


184-198: Add comments to clarify test case configurations

In BenchmarkIBC_ProcessProposal_Update_Client_Multi, the testCases array specifies numberOfTransactions and numberOfValidators. Providing explanations for the chosen values can help others understand the benchmarking context and the relationship between the number of transactions and validators.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between a76ffcc and 1ed45b1.

📒 Files selected for processing (3)
  • app/benchmarks/benchmark_ibc_update_client_test.go (1 hunks)
  • app/benchmarks/benchmark_msg_send_test.go (1 hunks)
  • app/benchmarks/benchmark_pfb_test.go (1 hunks)
🧰 Additional context used
🔇 Additional comments (11)
app/benchmarks/benchmark_msg_send_test.go (4)

284-308: Minor improvements for generateMsgSendTransactions helper function.

The generateMsgSendTransactions function is well-implemented, but consider the following improvements:

  1. Add error handling for testutil.SetupTestAppWithGenesisValSetAndMaxSquareSize.
  2. Consider using a constant for the MaxSquareSize parameter (128).
  3. Use a named return value for better documentation.

Here's a suggested improvement:

-func generateMsgSendTransactions(b *testing.B, count int) (*app.App, [][]byte) {
+func generateMsgSendTransactions(b *testing.B, count int) (testApp *app.App, rawTxs [][]byte) {
+	const maxSquareSize = 128
 	account := "test"
-	testApp, kr := testutil.SetupTestAppWithGenesisValSetAndMaxSquareSize(app.DefaultConsensusParams(), 128, account)
+	var err error
+	testApp, kr, err := testutil.SetupTestAppWithGenesisValSetAndMaxSquareSize(app.DefaultConsensusParams(), maxSquareSize, account)
+	require.NoError(b, err)
 	addr := testfactory.GetAddress(kr, account)
 	enc := encoding.MakeConfig(app.ModuleEncodingRegisters...)
 	acc := testutil.DirectQueryAccount(testApp, addr)
 	signer, err := user.NewSigner(kr, enc.TxConfig, testutil.ChainID, appconsts.LatestVersion, user.NewAccount(account, acc.GetAccountNumber(), acc.GetSequence()))
 	require.NoError(b,

---

`118-139`: _:hammer_and_wrench: Refactor suggestion_

**Optimize PrepareProposal benchmark for 8MB of transactions.**

The current implementation can be improved for more accurate results:

1. Run the benchmark for `b.N` iterations.
2. Consider adding a throughput metric using `b.SetBytes()`.

Here's a suggested improvement:

```diff
 func BenchmarkPrepareProposal_MsgSend_8MB(b *testing.B) {
 	// a full 8mb block equals to around 31645 msg send transactions.
 	// using 31645 to let prepare proposal choose the maximum
 	testApp, rawTxs := generateMsgSendTransactions(b, 31645)

 	blockData := &tmproto.Data{
 		Txs: rawTxs,
 	}
 	prepareProposalRequest := types.RequestPrepareProposal{
 		BlockData: blockData,
 		ChainId:   testApp.GetChainID(),
 		Height:    10,
 	}

+	totalBytes := int64(0)
+	for _, tx := range rawTxs {
+		totalBytes += int64(len(tx))
+	}
+	b.SetBytes(totalBytes)

 	b.ResetTimer()
-	resp := testApp.PrepareProposal(prepareProposalRequest)
-	b.StopTimer()
-	require.GreaterOrEqual(b, len(resp.BlockData.Txs), 1)
-	b.ReportMetric(float64(len(resp.BlockData.Txs)), "number_of_transactions")
-	b.ReportMetric(calculateBlockSizeInMb(resp.BlockData.Txs), "block_size(mb)")
-	b.ReportMetric(float64(calculateTotalGasUsed(testApp, resp.BlockData.Txs)), "total_gas_used")
+	for i := 0; i < b.N; i++ {
+		resp := testApp.PrepareProposal(prepareProposalRequest)
+		require.GreaterOrEqual(b, len(resp.BlockData.Txs), 1)
+		b.ReportMetric(float64(len(resp.BlockData.Txs)), "number_of_transactions")
+		b.ReportMetric(calculateBlockSizeInMb(resp.BlockData.Txs), "block_size(mb)")
+		b.ReportMetric(float64(calculateTotalGasUsed(testApp, resp.BlockData.Txs)), "total_gas_used")
+	}
 }

These changes will provide more accurate benchmarking results by running for multiple iterations and reporting throughput in bytes per second.

Likely invalid or redundant comment.


65-78: 🛠️ Refactor suggestion

Improve benchmark accuracy for DeliverTx with a single transaction.

The current implementation only runs the benchmark once. To get more accurate results:

  1. Move b.ResetTimer() just before the operation being measured.
  2. Run the benchmark for b.N iterations.

Here's a suggested improvement:

 func BenchmarkDeliverTx_MsgSend_1(b *testing.B) {
 	testApp, rawTxs := generateMsgSendTransactions(b, 1)

 	deliverTxRequest := types.RequestDeliverTx{
 		Tx: rawTxs[0],
 	}

 	b.ResetTimer()
-	resp := testApp.DeliverTx(deliverTxRequest)
-	b.StopTimer()
-	require.Equal(b, uint32(0), resp.Code)
-	require.Equal(b, "", resp.Codespace)
-	b.ReportMetric(float64(resp.GasUsed), "gas_used")
+	for i := 0; i < b.N; i++ {
+		resp := testApp.DeliverTx(deliverTxRequest)
+		require.Equal(b, uint32(0), resp.Code)
+		require.Equal(b, "", resp.Codespace)
+		b.ReportMetric(float64(resp.GasUsed), "gas_used")
+	}
 }

This change ensures that the benchmark runs for the correct number of iterations and only measures the time taken by DeliverTx.

Likely invalid or redundant comment.


141-173: 🛠️ Refactor suggestion

Improve ProcessProposal benchmark accuracy for a single transaction.

The current implementation only runs the benchmark once. To get more accurate results:

  1. Run the benchmark for b.N iterations.
  2. Consider adding a throughput metric using b.SetBytes().

Here's a suggested improvement:

 func BenchmarkProcessProposal_MsgSend_1(b *testing.B) {
 	testApp, rawTxs := generateMsgSendTransactions(b, 1)

 	blockData := &tmproto.Data{
 		Txs: rawTxs,
 	}
 	prepareProposalRequest := types.RequestPrepareProposal{
 		BlockData: blockData,
 		ChainId:   testApp.GetChainID(),
 		Height:    10,
 	}
 	prepareProposalResponse := testApp.PrepareProposal(prepareProposalRequest)
 	require.GreaterOrEqual(b, len(prepareProposalResponse.BlockData.Txs), 1)

 	processProposalRequest := types.RequestProcessProposal{
 		BlockData: prepareProposalResponse.BlockData,
 		Header: tmproto.Header{
 			Height:   1,
 			DataHash: prepareProposalResponse.BlockData.Hash,
 			ChainID:  testutil.ChainID,
 			Version: version.Consensus{
 				App: testApp.AppVersion(),
 			},
 		},
 	}

+	b.SetBytes(int64(len(rawTxs[0])))
 	b.ResetTimer()
-	resp := testApp.ProcessProposal(processProposalRequest)
-	b.StopTimer()
-	require.Equal(b, types.ResponseProcessProposal_ACCEPT, resp.Result)
-
-	b.ReportMetric(float64(calculateTotalGasUsed(testApp, prepareProposalResponse.BlockData.Txs)), "total_gas_used")
+	for i := 0; i < b.N; i++ {
+		resp := testApp.ProcessProposal(processProposalRequest)
+		require.Equal(b, types.ResponseProcessProposal_ACCEPT, resp.Result)
+		b.ReportMetric(float64(calculateTotalGasUsed(testApp, prepareProposalResponse.BlockData.Txs)), "total_gas_used")
+	}
 }

These changes will provide more accurate benchmarking results by running for multiple iterations and reporting throughput in bytes per second.

Likely invalid or redundant comment.

app/benchmarks/benchmark_pfb_test.go (7)

5-25: Import statements look good

The necessary packages for benchmarking, crypto operations, and Celestia-specific modules are correctly imported. There are no unused imports.


27-29: Initialization looks good

Setting TestAppLogger to a no-op logger in the init function is a good practice for benchmarks. This prevents logging overhead from affecting the benchmark results.


60-76: Function structure looks good, but iteration issue was addressed in previous comment


107-125: Function structure looks good, but iteration issue was addressed in previous comment


156-177: Function structure looks good, but iteration issue was addressed in previous comment


208-245: Function structure looks good, but iteration issue was addressed in previous comment


247-269: Benchmark structure is appropriate for its purpose

The BenchmarkProcessProposal_PFB_Half_Second function is well-structured for its specific purpose of finding the maximum number of transactions that can be processed within half a second. It doesn't use b.N for iterations, which is appropriate in this case as it's measuring against a specific time constraint rather than running for a fixed number of iterations.

app/benchmarks/benchmark_msg_send_test.go Show resolved Hide resolved
app/benchmarks/benchmark_msg_send_test.go Show resolved Hide resolved
app/benchmarks/benchmark_msg_send_test.go Show resolved Hide resolved
app/benchmarks/benchmark_msg_send_test.go Show resolved Hide resolved
app/benchmarks/benchmark_msg_send_test.go Show resolved Hide resolved
app/benchmarks/benchmark_pfb_test.go Show resolved Hide resolved
app/benchmarks/benchmark_pfb_test.go Show resolved Hide resolved
app/benchmarks/benchmark_pfb_test.go Show resolved Hide resolved
app/benchmarks/benchmark_pfb_test.go Show resolved Hide resolved
evan-forbes
evan-forbes previously approved these changes Oct 18, 2024
@celestia-bot celestia-bot requested review from a team and evan-forbes and removed request for a team October 18, 2024 20:30
Copy link
Collaborator

@rootulp rootulp left a comment

Choose a reason for hiding this comment

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

Still LGTM, very thorough work!

Comment on lines +310 to +311
// megabyte the number of bytes in a megabyte
const megabyte = 1048576
Copy link
Collaborator

Choose a reason for hiding this comment

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

[uber nit] this is the number of bytes in a mebibyte

Suggested change
// megabyte the number of bytes in a megabyte
const megabyte = 1048576
// mebibyte the number of bytes in a mebibyte
const mebibyte = 1048576

Screenshot 2024-10-20 at 9 47 55 PM
Screenshot 2024-10-20 at 9 47 47 PM

@rach-id rach-id merged commit d4eb75e into main Oct 21, 2024
33 checks passed
@rach-id rach-id deleted the 8mb-benchmark branch October 21, 2024 06:22
rach-id added a commit that referenced this pull request Oct 21, 2024
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.

4 participants