mirror of
https://github.com/protocolbuffers/protobuf
synced 2026-08-26 02:23:14 -04:00
Implements 64-bit SWAR chunking via ByteBuffer on non-Android devices, falling back to a scalar countdown loop on Android devices. Sub-8 byte inputs bypass 64-bit chunking and fall through to scalar counting. ### JMH Microbenchmark Results (VarintCountingBenchmark) | Payload Length | Scalar Baseline | SWAR (ByteBuffer) | Speedup | | :--- | :--- | :--- | :--- | | 1 B | 1.78 ns/op | 1.91 ns/op | 1.0x (parity) | | 4 B | 3.75 ns/op | 3.65 ns/op | 1.0x (parity) | | 8 B | 6.19 ns/op | 3.44 ns/op | 1.8x faster | | 16 B | 9.93 ns/op | 4.00 ns/op | 2.5x faster | | 32 B | 18.58 ns/op | 5.06 ns/op | 3.7x faster | | 64 B | 35.50 ns/op | 7.51 ns/op | 4.7x faster | | 128 B | 74.66 ns/op | 10.92 ns/op | 6.8x faster | | 1024 B | 641.02 ns/op | 75.63 ns/op | 8.5x faster | PiperOrigin-RevId: 966557820 |
||
|---|---|---|
| .. | ||
| src | ||
| BUILD.bazel | ||
| generate-sources-build.xml | ||
| generate-test-sources-build.xml | ||
| pom_template.xml | ||