Commit b6b85df
cpp, go: default LZ4 to fast mode, matching the other writers (#1807)
### Changelog
The C++ and Go writers' default LZ4 compression was changed from the
high-compression codepaths (LZ4HC level 9 and pierrec Level3
respectively) to fast mode, matching the Rust and Python writers.
Default LZ4 writes get roughly 3-5x faster and produce files roughly
15-30% larger. Callers that prefer ratio over speed can keep the old
behavior through the existing slower CompressionLevel settings.
### Docs
None.
### Description
CompressionLevel::Default diverged for LZ4 across the writers: C++
mapped it to LZ4HC_CLEVEL_DEFAULT (LZ4HC level 9) and Go to pierrec
lz4.Level3, while Rust and Python compress in LZ4's fast mode.
(TypeScript does not ship an LZ4 writer.) High-compression LZ4 defeats
the reason to pick LZ4 in the first place: both writers' own zstd
defaults strictly dominate their LZ4 defaults after #1804 — on the same
workload C++ zstd wrote in 710 ms producing a 71 MB file while C++ LZ4
took 2130 ms to produce 78 MB, slower and larger. Users choosing LZ4
over zstd are choosing speed.
Map CompressionLevel::Default to fast mode in both writers. On 1M
100-byte messages sharing one payload blob:
- C++: 2.23 s -> 0.46 s (~4.8x faster), 81 MB -> 103 MB
- Go: 2.19 s -> 0.77 s (~2.9x faster), 82 MB -> 93 MB
- Rust, for reference, writes the same workload in 0.67 s at its
existing fast-mode default.
The high-compression levels remain reachable: C++ keeps LZ4HC through
CompressionLevel::Slow (LZ4HC_CLEVEL_OPT_MIN) and Slowest
(LZ4HC_CLEVEL_MAX), and Go keeps lz4.Level6/Level9 through
CompressionLevelBetter/Best. Go's fallback for unknown level values also
follows the default to fast mode, mirroring how its zstd mapping falls
back to its own default.
As with #1804, rosbag2 is unaffected out of the box since it defaults to
uncompressed writing.
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>1 parent 45b64e3 commit b6b85df
2 files changed
Lines changed: 9 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
165 | 165 | | |
166 | 166 | | |
167 | 167 | | |
168 | | - | |
169 | 168 | | |
170 | 169 | | |
171 | | - | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
172 | 174 | | |
173 | 175 | | |
174 | 176 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
899 | 899 | | |
900 | 900 | | |
901 | 901 | | |
902 | | - | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
903 | 906 | | |
904 | 907 | | |
905 | 908 | | |
906 | 909 | | |
907 | 910 | | |
908 | 911 | | |
909 | 912 | | |
910 | | - | |
| 913 | + | |
911 | 914 | | |
912 | 915 | | |
913 | 916 | | |
| |||
0 commit comments