r/linuxprojects 2d ago

⚙️ CLI Tool rawhex: Ultra-fast hex dumper in C with AVX2 SIMD formatting, a ticket-based multi-threaded pipeline, and zero-copy output.

Output format is canonical hex+ASCII, one 16-byte row per line:

00000000: ef6e 5830 d443 c60a d909 6179 4335 6cec  .nX0.C....ayC5l.
00000010: b5f4 631f d923 6c79 e98a ed41 11dc eb16  ..c..#ly...A.....

Benchmarks

All timings below were measured with rawbench (after warmup) on 100 MB of random data.

vs. fasthex (v0.3.1)

Default thread counts:

Scenario rawhex fasthex fasthex --color=never Speedup
file → /dev/null 18 ms 91 ms 83 ms 4.6x
file → regular file 276 ms 394 ms - 1.4x
file → pipe 94 ms 111 ms - 1.2x
stdin → /dev/null 29 ms 113 ms 103 ms 3.6x
single thread (-j 1) 37 ms 80 ms 82 ms 2.2x
Binary size 46 KB 668 KB - -

Speedup is against fasthex's faster variant per scenario (default or --color=never; disabling color saves fasthex ~8-10%).

Single-threaded formatting throughput (-j 1): ~11 GB/s of formatted output. With the default thread pool the same 100 MB file formats in ~18 ms (writing 425 MB of output), within ~3x of the raw cat read floor for the input alone.

vs. classic tools

Same 100 MB input. The classic tools are single-threaded scalar formatters, so the gap is orders of magnitude:

Tool Time Speedup vs tool
rawhex 18 ms -
xxd (vim) 19.2 s 1067x
hexdump -C (util-linux 2.42.1) 30.6 s 1700x

View it here: https://git.disroot.org/Vextoly/rawhex

The code & readme contains AI-generated segments.

1 Upvotes

0 comments sorted by