Skip to content
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

core:: SIMD primitives not inlined with stable Rust (1.51.0) with target-cpu=native #189

Closed
hkratz opened this issue May 3, 2021 · 5 comments

Comments

@hkratz
Copy link
Contributor

hkratz commented May 3, 2021

I don't know why, but for some reason the SIMD core primitives are not being inlined if I build simd-json with stable Rust. It works fine with nightly (2021-04-23) though.

Stable:

$ cargo clean; RUSTFLAGS="-C target-cpu=native" cargo asm --rust simd_json::Deserializer::from_slice_with_buffers|grep core::
     call    core::core_arch::x86::avx::_mm256_setzero_si256
     call    core::core_arch::x86::avx::_mm256_setzero_si256
     call    core::core_arch::x86::avx::_mm256_setzero_si256
     call    core::core_arch::x86::avx::_mm256_loadu_si256
     [... 126 more lines elides ...]

Nightly:

$ cargo +nightly clean; RUSTFLAGS="-C target-cpu=native" cargo +nightly asm --rust simd_json::Deserializer::from_slice_w
ith_buffers|grep core::|wc -l
0

This leads to much worse performance on stable.

Benchmarks

Stable:

apache_builds/simd_json::to_tape
                        time:   [372.11 us 373.84 us 376.01 us]
                        thrpt:  [334.02 MiB/s 335.95 MiB/s 337.52 MiB/s]

Nightly:

[...]
apache_builds/simd_json::to_tape
                        time:   [67.727 us 68.317 us 68.884 us]
                        thrpt:  [1.7805 GiB/s 1.7953 GiB/s 1.8109 GiB/s]
[...]

@hkratz hkratz changed the title core:: primitives not inlined with stable Rust (1.51.0) core:: SIMD primitives not inlined with stable Rust (1.51.0) May 3, 2021
@hkratz
Copy link
Contributor Author

hkratz commented May 3, 2021

Ahh, that is a known issue which was fixed during the beta but not backported to 1.51.0. Urgh.

Not sure if we want to do something in the docs about this given that this is what is recommended in the README. Leaving open for triage.

@hkratz hkratz changed the title core:: SIMD primitives not inlined with stable Rust (1.51.0) core:: SIMD primitives not inlined with stable Rust (1.51.0) with target-cpu=native May 3, 2021
@Licenser
Copy link
Member

Licenser commented May 4, 2021

This is a really great find! Perhaps we should change the REAME to suggest using target-feature=+avx,+avx2,+sse4.2 instead? I can make this change but since you found it I don't want to steal the contribution :)

@hkratz
Copy link
Contributor Author

hkratz commented May 4, 2021

This is a really great find! Perhaps we should change the REAME to suggest using target-feature=+avx,+avx2,+sse4.2 instead? I can make this change but since you found it I don't want to steal the contribution :)

Rust 1.52 is scheduled to be released in two days and I have verified that it is fixed in that version. So I think we can get away with not changing the docs and just closing this after a while as this bug really only affects Rust 1.51.

@hkratz
Copy link
Contributor Author

hkratz commented May 13, 2021

Confirmed fixed in 1.52 and not the fault of simd-json anyway.

@hkratz hkratz closed this as completed May 13, 2021
@Licenser
Copy link
Member

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants