Snappy benchmarks + introduce aircompressor#10861
Conversation
|
Snappy defines the compressed format, but not the encoder heuristics. Two valid implementations may produce different compressed sizes for the same input, so comparing encode speed alone is incomplete. A fair benchmark should also report compression ratio / compressed payload size. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Reviewed by Cursor Bugbot for commit 433d276. Configure here.
|
|
||
| public double rawToEncodedRatio() { | ||
| return rawToEncodedRatio; | ||
| } |
There was a problem hiding this comment.
Wrong JMH compression ratio
Medium Severity
CompressionMetrics uses @AuxCounters(Type.EVENTS) with a double rawToEncodedRatio() getter and divides the ratio by measurementCount on every benchmark invocation. JMH treats floating-point aux counters as VALUES (last value per iteration), and EVENTS sums per-invocation deltas for integral counters—not once per measurement iteration—so the reported compression ratio is wrong or missing.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 433d276. Configure here.
|
Nice catch. I've added compression ratio to the benchmark. Though we have definitely different implementations, I think they behave similar: So both codecs are useless on RANDOM data and both are pretty similar on REPEATING. The difference is only on MIXED: snappyJava doesn't compress small chunks 64kb and less, netty is opposite, it compresses small chunks but not big. Maybe there is a way to configure it, not compressing big chunks looks like optimization, but the speed is not good for netty anyway. |
|
I have a set of benchmarks with an alternative library that seems a promising way forward. Unfortunately, didn't have time to document it yet. Will do on Monday. |
…le payloads to Snappy benchmark
|
reworked over Lucas's benchmarks from https://github.com/lucassaldanha/teku/blob/feature/snappy-benchmark/eth-benchmark-tests/src/jmh/java/tech/pegasys/teku/benchmarks/networking/SnappyCompressionBenchmark.java
|
is the pr description updated with latest results? |


PR Description
Speed (µs/op, lower is better)
Compression ratio
TLDR;
snappy-java(JNI) andaircompressor-nativeare bothGoogle's C libsnappyunderneath, they always have pretty close numbers,nettyis always way slower but it's better onSynthetic mixed 64 KBbenchmark in compression ratio (only one time when it wins), but the reason is it's very synthetic benchmark having 32 KB random + 32 KB repeating, which is very uncommon for real data, so we shouldn't care on this.Fixed Issue(s)
Documentation
doc-change-requiredlabel to this PR if updates are required.Changelog
Note
Low Risk
Benchmark-only changes in eth-benchmark-tests with no runtime networking or codec behavior modified in production modules.
Overview
Adds JMH microbenchmarks in
eth-benchmark-teststo compare Snappy block compression for gossip-style workloads: snappy-java (current gossip), Netty (current RPC), and aircompressor-v3 (FFM native + pure Java). The goal is data to support consolidating on a single Snappy library later.SnappyCompressionBenchmarkparametrizes payload type (SSZ messages, 32 KB beacon-block/data-column chunks, synthetic compressible data) and implementation. It measures compress/decompress throughput and reports compression ratio via a newCompressionMetricsaux counter. On startup (snappy-java trials),verifyCrossCompatibilityfails fast if any codec cannot round-trip the Snappy block wire format with snappy-java.Fixture support:
BeaconBlockFixtureGeneratorplusBlockIO.readResourceBytesload gzipped Deneb beacon-block SSZ from/snappy/beacon-blocks-deneb.ssz.gz(regenerate via:eth-benchmark-tests:generateBeaconBlockFixture). The benchmarks README documents example./gradlew :eth-benchmark-tests:jmhinvocations with-prof gcand payload/impl filters.Dependencies are scoped to JMH only:
netty-handler,snappy-java, andaircompressor-v3on the benchmark classpath—no production gossip/RPC code is switched in this diff.Reviewed by Cursor Bugbot for commit e32aa2e. Bugbot is set up for automated code reviews on this repo. Configure here.