Commit 0c81ad3
committed
perf(qwp): fuse per-frame CRC into one native call in MmapSegment.tryAppend
The append hot path computed the frame CRC-32C with two Crc32c.update
JNI calls -- one over the u32 payloadLen field, one over the payload --
even though the layout [u32 crc][u32 payloadLen][payload] places the
payload immediately after payloadLen (at lenAddr+4). The two CRC'd
regions are physically contiguous, so a single update over 4 + payloadLen
bytes yields the byte-identical CRC while crossing the JNI boundary once
per frame instead of twice.
This is the same form the recovery scanner already recomputes
(reader.crc32c(pos + 4, 4 + payloadLen) in scanForRecovery), which
validates every on-disk frame against the producer-written CRC, so the
fused value is guaranteed identical and the round-trip is unchanged.
No behavior change, no change to hashed or written bytes; saves one
native-call dispatch per non-empty frame on the producer's zero-alloc
hot path. Verified by MmapSegmentTest and MmapSegmentRecoveryFaultTest.1 parent 178fbe9 commit 0c81ad3
1 file changed
Lines changed: 6 additions & 5 deletions
Lines changed: 6 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
554 | 554 | | |
555 | 555 | | |
556 | 556 | | |
557 | | - | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
558 | 562 | | |
559 | 563 | | |
560 | 564 | | |
561 | 565 | | |
562 | 566 | | |
563 | | - | |
564 | | - | |
565 | | - | |
566 | | - | |
| 567 | + | |
567 | 568 | | |
568 | 569 | | |
569 | 570 | | |
| |||
0 commit comments