Conversation
Dead2
commented
Nov 13, 2025
- Unify crc32_chorba, chorba_sse2 and chorba_sse41 dispatch functions.
- Fix alignment calculation in crc32_chorba.
- Fix length check to happen early, avoiding several extra branches for too short lengths, this also allows removing one function call to crc32_braid_internal to handle fallthrough. Gbench shows ~0.15-0.25ns saved per call for lengths shorter than CHORBA_SMALL_THRESHOLD.
- Avoid calculating aligned len if buffer is already aligned
- Fixed alignment diff calculation in crc32_chorba. - Fixed length check to happen early, avoiding extra branches for too short lengths, this also allows removing one function call to crc32_braid_internal to handle those. Gbench shows ~0.15-0.25ns saved per call for lengths shorter than CHORBA_SMALL_THRESHOLD. - Avoid calculating aligned len if buffer is already aligned
WalkthroughRefactors CRC32 Chorba implementations across multiple architectures to introduce alignment-aware processing with multi-path dispatching based on input size thresholds. Consolidates control flow in generic C and SSE2/SSE4.1 codepaths, and updates threshold macro definitions in crc32.h to be conditionally based on OPTIMAL_CMP. Changes
Sequence DiagramsequenceDiagram
participant Caller
participant crc32_chorba
participant Alignment as Alignment Check
participant LargePath as Large Path<br/>(118960)
participant MediumPath as Medium Path<br/>(32768)
participant SmallPath as Small Path
participant BraidPath as Braid Path
Caller->>crc32_chorba: input buffer, length, crc
crc32_chorba->>Alignment: calculate algn_diff
alt len > algn_diff + THRESHOLD
Alignment->>Alignment: align buffer
note over Alignment: Process aligned portion
alt len > LARGE_THRESHOLD
Alignment->>LargePath: crc32_chorba_118960_nondestructive
LargePath-->>crc32_chorba: processed crc
else len in medium window (OPTIMAL_CMP==64)
Alignment->>MediumPath: crc32_chorba_32768_nondestructive
MediumPath-->>crc32_chorba: processed crc
else
Alignment->>SmallPath: crc32_chorba_small_nondestructive
SmallPath-->>crc32_chorba: processed crc
end
else
Alignment->>BraidPath: crc32_braid_internal
BraidPath-->>crc32_chorba: processed crc
end
crc32_chorba->>Caller: finalized crc (XOR 0xffffffff)
Possibly related PRs
Suggested labels
Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (4)
🧰 Additional context used🧠 Learnings (10)📓 Common learnings📚 Learning: 2025-01-23T22:01:53.422ZApplied to files:
📚 Learning: 2025-02-21T01:42:40.488ZApplied to files:
📚 Learning: 2025-02-21T01:41:50.358ZApplied to files:
📚 Learning: 2025-02-23T16:49:52.043ZApplied to files:
📚 Learning: 2025-02-21T01:44:03.996ZApplied to files:
📚 Learning: 2024-12-25T19:45:06.009ZApplied to files:
📚 Learning: 2025-06-09T16:46:28.468ZApplied to files:
📚 Learning: 2025-02-21T01:37:54.508ZApplied to files:
📚 Learning: 2024-12-22T20:40:03.280ZApplied to files:
🔇 Additional comments (4)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
LGTM |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #2006 +/- ##
===========================================
- Coverage 83.21% 78.99% -4.22%
===========================================
Files 160 160
Lines 12955 13691 +736
Branches 3145 3459 +314
===========================================
+ Hits 10780 10815 +35
- Misses 1138 1831 +693
- Partials 1037 1045 +8 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|