Redis, BSON, MessagePack, TSV & dB: Binary & Data Plumbing
September 5, 2026 · DevTools
Serialization bugs and capacity surprises share a root cause: nobody looked at the bytes. These five tools make the invisible concrete: Redis RDB Memory Estimator, TSV Matrix Transposer & Normalizer, BSON to JSON & Hex Decoder, MessagePack & CBOR Inspector, and Audio dBFS, dBu, dBV & Voltage Converter.
Size Redis before the eviction storm
estimateRedisMemory models strings, hashes, lists, sets, and sorted sets from key patterns, applying a 50-byte SDS allocator allowance rounded to 8 bytes, compact encoding thresholds (listpack/ziplist cutovers), global overhead, and replication backlog notes. That allocator rounding is the detail naive calculators miss: ten million small keys each waste a few bytes to alignment, which compounds into gigabytes.
pattern session:* string avg 240 B × 2,000,000
→ per-key SDS + dict overhead, compact-element check, global share
→ total RSS estimate + replication backlog note
Feed it real key samples from SCAN, not schema guesses — average value size dominates the result, and one oversized session blob skews everything.
Transpose ragged matrices without breaking the numbers
parseDelimitedMatrix reads TSV, CSV, or custom-delimited input with quoted fields, reports irregular rows, and truncates safely. processMatrix then pads ragged rows, fills missing cells with zero, median, or a custom value, normalizes rows or columns with min-max or z-score, skips selected rows or columns, and previews the first 20 output rows before you commit.
| Task | Option | When to use it |
|---|---|---|
| Empty cells in sensor logs | fill median | robust to outliers |
| Features for a heatmap | min-max per column | bounded 0–1 range |
| Features for k-NN | z-score per column | distance needs unit variance |
Normalize columns, not rows, when features live in columns — row normalization destroys cross-sample comparability and silently ruins distance-based models.
Read BSON, MessagePack, and CBOR at the byte level
encodeBson and decodeBson round-trip nested documents, arrays, int32, int64, doubles, booleans, null, and ObjectId values, while hexToBytes, bytesToHex, and hexDump render the classic offset/hex/ASCII view so you can spot trailing bytes or a wrong length prefix. decodeBson throws on trailing bytes instead of silently ignoring them — a genuine footgun when concatenating wire captures.
inspectJson takes JSON input and encodes it deterministically as MessagePack or CBOR, returning the hex plus a recursive byte tree with per-node offsets, header bytes, and decoded values. Comparing the same payload in both formats side by side shows exactly where CBOR's major-type headers diverge from MessagePack's fixint/fixstr prefixes, which settles format debates with evidence instead of README claims.
Convert audio levels without frying the input stage
convertAudioLevel translates between dBFS, dBu, dBV, volts, and linear amplitude using 20·log10 scaling, the 0.7746 V dBu reference, and the 1 V dBV reference. resolveFullScale pins digital full scale to a convention — professional +24 dBu or consumer −10 dBV — with custom full-scale voltage supported, plus peak/RMS guidance. The reference examples map −6 dBFS steps to amplitude so gain-staging math stays anchored: −6 dBFS is half amplitude, −12 dBFS a quarter, every time.
Try Them
- Redis RDB Memory Estimator — SDS overhead, compact thresholds, and backlog notes.
- TSV Matrix Transposer & Normalizer — transpose, fill, and normalize delimited matrices.
- BSON to JSON & Hex Decoder — byte-level BSON with classic hex dumps.
- MessagePack & CBOR Inspector — dual-format byte trees with offsets and headers.
- Audio dBFS, dBu, dBV & Voltage Converter — pro and consumer references with peak/RMS guidance.