simd-json
simd-json copied to clipboard
runtime dispatch and other goodies from upstream
One idea we should consider soonish is compiling everything for the target architecture regardless of CPU features and doing runtime detection & dispatch (as implemented in upstream, hopefully easier in Rust?).
There might be other goodies in upstream as well...
I got no idea how that'd work in rust but that just means we got to learn something new :D
I’ll have a go at this. @Licenser can you assign this to me 😄 ?
Thanks @CJP10 go for it :)
I got no idea how that'd work in rust but that just means we got to learn something new :D
From what I understand you use something like is_x86_feature_detected!("ssse3") to detect whether a particular feature is available. Then you call a function optimized for that feature. You have to mark the function with #[target_feature(enable = "ssse3")] to force usage of that feature within the function.
@AndreKR upstream does something similar to ifunc.
Ja, we probably want something resembling the upstream solution that does only once include a conditional and after that memorizes the choice.
To add, we should also have a simd_json::init(). Which would be optional but perform the runtime selection outside of the hot path.
Yes very good idea 👍 that way applications who want to make sure there is 0 overhead on the hot path can call it on startup :), good thinking!
Maybe take some inspiration from rust-memchr: ifunc-like macro for Rust