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
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
91b40ae
chore: add benchmarks for msg send in 8mb
rach-id Sep 25, 2024
5092439
chore: run benchmarks multiple times
rach-id Sep 25, 2024
7335643
chore: two decimals after comma in block size
rach-id Sep 25, 2024
9c0742e
chore: add 8b check tx and deliver tx
rach-id Sep 26, 2024
ff28c12
chore: add PFB benchmarks
rach-id Sep 27, 2024
53177d8
chore: initial ibc client update benchmarks
rach-id Sep 28, 2024
a260476
chore: create the ibc client before updating it
rach-id Sep 30, 2024
3511b4b
chore: working update client transaction
rach-id Sep 30, 2024
9345a2a
chore: working ibc update client benchmarks
rach-id Sep 30, 2024
62729ca
chore: checks on validity of benchmark + not working comment
rach-id Oct 1, 2024
95250f7
chore: ibc update client benchmarks working
rach-id Oct 1, 2024
8b083fa
chore: pfb benchmarks working
rach-id Oct 1, 2024
5a556b7
chore: msg send benchmarks working
rach-id Oct 1, 2024
68002b7
chore: fix ibc update client comment and reports
rach-id Oct 3, 2024
dab12d3
chore: add half second benchmarks
rach-id Oct 3, 2024
a18707d
chore: only report the result
rach-id Oct 10, 2024
7b386be
Merge remote-tracking branch 'origin/main' into 8mb-benchmark
rach-id Oct 17, 2024
ae7fb19
docs: add result docs
rach-id Oct 17, 2024
87c28e2
chore: move to benchmark folder
rach-id Oct 17, 2024
dd3dd6b
chore: revert unnecessary changes
rach-id Oct 17, 2024
3a5e979
chore: build tags
rach-id Oct 17, 2024
ce56501
chore: add readme and cosmetics
rach-id Oct 17, 2024
ecaaeb6
chore: index out of range fix
rach-id Oct 17, 2024
af52646
Update app/benchmarks/benchmark_msg_send_test.go
rach-id Oct 17, 2024
0742f18
Merge remote-tracking branch 'origin/8mb-benchmark' into 8mb-benchmark
rach-id Oct 17, 2024
0fb7b39
chore: check error when simulating transaction
rach-id Oct 17, 2024
12fea1c
chore: set number of iterations
rach-id Oct 17, 2024
2bd31ca
chore: use bench_abci_methods instead
rach-id Oct 17, 2024
ad76ff2
chore: remove unnecessarily duplicate no op logger set
rach-id Oct 17, 2024
3a4e835
chore: remove print statement
rach-id Oct 17, 2024
a76ffcc
Update app/benchmarks/README.md
rach-id Oct 18, 2024
9a45f4c
chore: rename to numberOfTransactions and blobSize
rach-id Oct 18, 2024
d60a1b4
Merge remote-tracking branch 'origin/8mb-benchmark' into 8mb-benchmark
rach-id Oct 18, 2024
1608073
Update app/benchmarks/benchmark_ibc_update_client_test.go
rach-id Oct 18, 2024
1ed45b1
chore: use megabyte const
rach-id Oct 18, 2024
0fc3483
Merge remote-tracking branch 'origin/main' into 8mb-benchmark
rach-id Oct 18, 2024
c6c6c81
chore: rename
rach-id Oct 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
178 changes: 178 additions & 0 deletions app/benchmark_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
package app_test

import (
"fmt"
"github.com/celestiaorg/celestia-app/v3/app"
"github.com/celestiaorg/celestia-app/v3/app/encoding"
"github.com/celestiaorg/celestia-app/v3/pkg/appconsts"
"github.com/celestiaorg/celestia-app/v3/pkg/user"
testutil "github.com/celestiaorg/celestia-app/v3/test/util"
"github.com/celestiaorg/celestia-app/v3/test/util/testfactory"
"github.com/celestiaorg/celestia-app/v3/test/util/testnode"
sdk "github.com/cosmos/cosmos-sdk/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/abci/types"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
"github.com/tendermint/tendermint/proto/tendermint/version"
"testing"
)

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

checkTxRequest := types.RequestCheckTx{
Tx: rawTxs[0],
Type: types.CheckTxType_New,
}

b.ResetTimer()
testApp.CheckTx(checkTxRequest)
}
rach-id marked this conversation as resolved.
Show resolved Hide resolved

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

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

b.ResetTimer()
testApp.DeliverTx(deliverTxRequest)
}
rach-id marked this conversation as resolved.
Show resolved Hide resolved

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

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

b.ResetTimer()
testApp.PrepareProposal(prepareProposalRequest)
}
rach-id marked this conversation as resolved.
Show resolved Hide resolved

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

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

b.ResetTimer()
prepareProposalResponse := testApp.PrepareProposal(prepareProposalRequest)
b.StopTimer()
rach-id marked this conversation as resolved.
Show resolved Hide resolved
testApp.Logger().Info("block prepared", "number of transactions", len(prepareProposalResponse.BlockData.Txs), "block size (mb)~", calculateBlockSizeInMb(prepareProposalResponse.BlockData.Txs))
}

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)

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.ResetTimer()
testApp.ProcessProposal(processProposalRequest)
}
rach-id marked this conversation as resolved.
Show resolved Hide resolved

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

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

testApp.Logger().Info("block prepared", "number of transactions", len(prepareProposalResponse.BlockData.Txs), "block size (mb)~", calculateBlockSizeInMb(prepareProposalResponse.BlockData.Txs))

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.ResetTimer()
testApp.ProcessProposal(processProposalRequest)
}
rach-id marked this conversation as resolved.
Show resolved Hide resolved

// generateMsgSendTransactions creates a test app then generates a number
// of valid msg send transactions.
func generateMsgSendTransactions(b *testing.B, count int) (*app.App, [][]byte) {
account := "test"
testApp, kr := testutil.SetupTestAppWithGenesisValSet(app.DefaultConsensusParams(), account)
addr := testfactory.GetAddress(kr, account)
enc := encoding.MakeConfig(app.ModuleEncodingRegisters...)
acc := testutil.DirectQueryAccount(testApp, addr)
accountSequence := acc.GetSequence()
signer, err := user.NewSigner(kr, enc.TxConfig, testutil.ChainID, appconsts.LatestVersion, user.NewAccount(account, acc.GetAccountNumber(), acc.GetSequence()))
require.NoError(b, err)
rawTxs := make([][]byte, 0, count)
for i := 0; i < count; i++ {
msg := banktypes.NewMsgSend(
addr,
testnode.RandomAddress().(sdk.AccAddress),
sdk.NewCoins(sdk.NewInt64Coin(appconsts.BondDenom, 10)),
)
rawTx, err := signer.CreateTx([]sdk.Msg{msg}, user.SetGasLimit(1000000), user.SetFee(10))
require.NoError(b, err)
rawTxs = append(rawTxs, rawTx)
accountSequence++
err = signer.SetSequence(account, accountSequence)
require.NoError(b, err)
}
return testApp, rawTxs
}

// calculateBlockSizeInMb returns the block size in mb given a set
// of raw transactions.
func calculateBlockSizeInMb(txs [][]byte) string {
numberOfBytes := 0
for _, tx := range txs {
numberOfBytes += len(tx)
}
mb := float64(numberOfBytes) / 1048576
return fmt.Sprintf("%.3f", mb)
}
2 changes: 1 addition & 1 deletion pkg/appconsts/initial_consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
const (
// DefaultGovMaxSquareSize is the default value for the governance modifiable
// max square size.
DefaultGovMaxSquareSize = 64
DefaultGovMaxSquareSize = 128

// DefaultMaxBytes is the default value for the governance modifiable
// maximum number of bytes allowed in a valid block.
Expand Down
2 changes: 1 addition & 1 deletion test/util/test_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func NewTestAppWithGenesisSet(cparams *tmproto.ConsensusParams, genAccounts ...s
Block: &abci.BlockParams{
// choose some value large enough to not bottleneck the max square
// size
MaxBytes: int64(appconsts.DefaultUpperBoundMaxBytes),
MaxBytes: cparams.Block.MaxBytes,
MaxGas: cparams.Block.MaxGas,
},
Evidence: &cparams.Evidence,
Expand Down
Loading