-
Notifications
You must be signed in to change notification settings - Fork 2
refactor: runtime detect simd features #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: runtime detect simd features #29
Conversation
47b30b9
to
1abe914
Compare
CodSpeed Performance ReportMerging #29 will degrade performances by 7.11%Comparing Summary
Benchmarks breakdown
Footnotes
|
d525b70
to
fff65a9
Compare
55b4022
to
5329627
Compare
d4b63fc
to
70b51da
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Refactors the codebase to implement runtime SIMD feature detection by copying and adapting source code from sonic-rs, replacing the compile-time detection provided by the sonic-simd crate. This enables better binary distribution compatibility across different hardware platforms.
- Adds local SIMD abstraction modules for different architectures (SSE2, AVX2, AVX512, NEON, and generic fallback)
- Implements runtime feature detection using
is_x86_feature_detected!
andis_aarch64_feature_detected!
- Refactors the main escape function to dynamically select SIMD implementations based on available CPU features
Reviewed Changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated 7 comments.
Show a summary per file
File | Description |
---|---|
src/simd/traits.rs | Defines portable SIMD traits and interfaces |
src/simd/v128.rs | Generic 128-bit SIMD implementation as fallback |
src/simd/sse2.rs | SSE2-specific SIMD implementation for x86/x86_64 |
src/simd/neon.rs | NEON-specific SIMD implementation for AArch64 |
src/simd/mod.rs | Module organization for SIMD implementations |
src/simd/bits.rs | Bitmask utilities and implementations |
src/simd/avx512.rs | AVX512-specific SIMD implementation |
src/simd/avx2.rs | AVX2-specific SIMD implementation |
src/simd/README.md | Documentation for the SIMD module |
src/lib.rs | Main library refactored for runtime SIMD detection |
benches/escape.rs | Added correctness assertions in benchmarks |
Cargo.toml | Removed sonic-simd dependency and added debug symbols |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
The sonic-simd crate detects SIMD features at compile time, which is inconvenient for binary distribution.
This PR copies the source code from sonic-rs and refactors it to include runtime SIMD feature detection. The implementation is not elegant but functions effectively.