Repository navigation
Use 16-bit symbol entries in the rANS 4x8 order-1 decoder - #163
Conversation
a918313 to
315334e
Compare
|
I tried it on x86-64 with gcc (11.4, so not current) and a test of Illumina NovaSeq quals (4 binning) showed master at 220MB/s decode and this PR at 198MB/s decode. So it's a 10% performance hit. With gcc16 on the same system, I see 302MB/s and 281MB/s So it all 3 cases master outperforms this PR. /proc/cpu claims "Intel Core Processor (Broadwell, IBRS)". (It's virtual) On a bare-metal Intel(R) Xeon(R) Platinum 8468 with gcc16 and clang21 I see: On AMD EPYC 7713 64-Core I'm guessing this is an x86 vs ARM difference, perhaps related to L1 cache sizes? |
|
I will check deeper Le 26 nov. 2026 à 13:43, James Bonfield ***@***.***> a écrit :jkbonfield left a comment (samtools/htscodecs#163)
I tried it on x86-64 with gcc (11.4, so not current) and a test of Illumina NovaSeq quals (4 binning) showed master at 220MB/s decode and this PR at 198MB/s decode. So it's a 10% performance hit.
With gcc16 on the same system, I see 302MB/s and 281MB/s
With clang21 it's 311MB/s and 283MB/s
So it all 3 cases master outperforms this PR. /proc/cpu claims "Intel Core Processor (Broadwell, IBRS)". (It's virtual)
On a bare-metal Intel(R) Xeon(R) Platinum 8468 with gcc16 and clang21 I see:
gcc16: master 546MB/s, PR 533MB/s
clang21: master 545MB/s, PR 541MB/s
On AMD EPYC 7713 64-Core
gcc16: master 304MB/s, PR 300MB/s
clang21: master 350MB/s, PR 344MB/s
I'm guessing this is an x86 vs ARM difference, perhaps related to L1 cache sizes?
I don't really see why it would be slower on x86, but haven't time currently to look into the assembly produced.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: ***@***.***>
|
|
I tried my q40b (old Illumina 40 distinct quals) file and it is marginally faster there. So once we start using more of the arrays then the smaller sizes matter, slightly. That was on the original VM machine that showed the biggest performance hit on the q4b file, but it was only from 258MB/s (master) to 260MB/s (PR) for clang21, and 235MB/s (master) to 240MB/s (PR) for gcc16. PS. Please also rebase as the MinGW CI config has been fixed so the tests pass |
start and freq always fit in 16 bits here. On AArch64, using RansDecSymbol instead of RansDecSymbol32 halves the per-context table and makes order-1 decode 5-11% faster on Illumina/HiFi qualities. On x86 the 16-bit entries are slower (up to 10% on 4-binned qualities): imul/sub can no longer take the table entry as a memory operand, so each field needs a separate movzwl. Other platforms keep RansDecSymbol32, and their generated code is unchanged. Idea from pasta (https://github.com/DylanCosto/pasta, MIT). Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Benjamin Demaille <benjamin.demaille@icloud.com>
315334e to
bff981d
Compare
|
Thanks for testing on so many machines. I looked at the x86-64 code (clang -O2) for the order-1 inner loop, and it explains what you're seeing. With So I've made the 16-bit entries AArch64-only ( If you'd rather not carry a platform-specific path for ~5–10% on ARM with many-symbol data, I'm also fine with closing this. |
|
Thanks. That's pretty much how I hoped you'd resolve it, with a typedef. |
I noticed that
rans_uncompress_O1stores start/freq as twouint32_tper (context, symbol), but both always fit in 16 bits there (freq <= 4096 after the totals check, start < 4096). I switched it to the existingRansDecSymbol. That halves the table, and the scratch buffer goes from 1.5 MB to 1.25 MB. It's a 5-line change.I compared full decodes with master, and ran a differential fuzz against master (27k mutated order-1 streams, under ASan): same results, no reports.
make checkpasses.Order-1 decode, one thread on my M4 Max: Illumina qualities went from 584 to 615 MB/s and HiFi from 339 to 377 MB/s; q4 was flat. I haven't measured it on x86-64.
It was prompted by pasta (https://github.com/DylanCosto/pasta, MIT).
I've listed this with my other performance PRs in samtools/htslib#2175.
Assisted-by: Claude:claude-opus-5-5