-
Notifications
You must be signed in to change notification settings - Fork 474
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
Conversation
Codecov Report
@@ 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
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
@@ -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) { |
There was a problem hiding this comment.
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'
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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")) |
There was a problem hiding this comment.
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()) |
There was a problem hiding this comment.
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])) |
There was a problem hiding this comment.
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.
This was helpful but no longer needed |
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.