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

benchmark: add BenchmarkBlockEncoding #4590

Closed
wants to merge 3 commits into from

Conversation

cce
Copy link
Contributor

@cce cce commented Sep 26, 2022

Summary

This is a simple benchmark, built on Shant's block validation benchmark support code in #4522, to benchmark the encoding time of a full block.

Test Plan

No changes except this additional benchmark.

@codecov
Copy link

codecov bot commented Sep 27, 2022

Codecov Report

Merging #4590 (6434661) into master (ad08f74) will decrease coverage by 0.03%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master    #4590      +/-   ##
==========================================
- Coverage   54.47%   54.44%   -0.04%     
==========================================
  Files         407      407              
  Lines       52389    52389              
==========================================
- Hits        28541    28522      -19     
- Misses      21460    21474      +14     
- Partials     2388     2393       +5     
Impacted Files Coverage Δ
ledger/roundlru.go 90.56% <0.00%> (-5.67%) ⬇️
crypto/merkletrie/trie.go 66.42% <0.00%> (-2.19%) ⬇️
agreement/cryptoVerifier.go 67.60% <0.00%> (-2.12%) ⬇️
agreement/proposalManager.go 96.07% <0.00%> (-1.97%) ⬇️
network/wsPeer.go 66.50% <0.00%> (-1.95%) ⬇️
crypto/merkletrie/node.go 91.62% <0.00%> (-1.87%) ⬇️
cmd/tealdbg/debugger.go 72.69% <0.00%> (-0.81%) ⬇️
catchup/service.go 68.88% <0.00%> (-0.50%) ⬇️
network/wsNetwork.go 65.80% <0.00%> (+0.27%) ⬆️
ledger/blockqueue.go 88.50% <0.00%> (+2.87%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@cce cce requested a review from brianolson October 26, 2022 01:46
@@ -636,3 +639,52 @@ func callAppTransaction(
appTx.Type = protocol.ApplicationCallTx
return
}

// BenchmarkBlockEncoding builds a full block of pay transactions and benchmarks the time it takes to encode b.N of them.
func BenchmarkBlockEncoding(b *testing.B) {
Copy link
Contributor

Choose a reason for hiding this comment

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

misnamed? This is really a benchmark of zstd compression at some level? I was expecting a benchmark around the msgp operation as 'encoding'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh right, it was benchmarking the encoding before, and then I moved the place where ResetTimer and StopTimer was surrounding when Pavel started implementing block compression

currentRound := bc.round
for bc.round == currentRound {
// add pay transaction
//payEvent(bc, mrand.Float64() < newAcctProb)
Copy link
Contributor

Choose a reason for hiding this comment

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

cleanup?

//newAcctProb := 0.0
//newAcctProb := 1.0
bc := setupEnv(b, numAccts)
zstdLevel, err := strconv.Atoi(os.Getenv("ZSTD_LEVEL"))
Copy link
Contributor

Choose a reason for hiding this comment

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

who sets this env variable?

payEvent(bc, false)
}
if (currentRound+1)*10%(2*numBlocks) == 0 {
fmt.Printf("%d%% %.1fs ", (currentRound+1)*100/numBlocks, time.Since(s3).Seconds())
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: use b.Logf or fmt.Printf. Mixing them is confusing.

b.ResetTimer()
for i := range encs {
zstdbufs[i], err = zstd.CompressLevel(nil, encs[i], zstdLevel)
b.Logf("zstd compress size: %d orig: %d", len(zstdbufs[i]), len(encs[i]))
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not very useful (i.e. printing a line for each). Will be nice to collect the stats are print at the end as a summary of mean/median of the compression ratio.
Also, this may also impact the accuracy of the time measurement.

@cce
Copy link
Contributor Author

cce commented Jul 21, 2023

This was helpful but no longer needed

@cce cce closed this Jul 21, 2023
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.

3 participants