ogxd / gxhash

The fastest hashing algorithm 📈
https://docs.rs/gxhash
MIT License
766 stars 26 forks source link

cargo bench --no-fail-fast -F=avx2 failed #43

Closed 3tieto closed 9 months ago

3tieto commented 9 months ago

image

     Running benches/hashset.rs (target/release/deps/hashset-e0bfa844d705dd83)
Gnuplot not found, using plotters backend
HashSet/u32/Default Hasher
                        time:   [16.380 ns 16.711 ns 17.067 ns]
Found 1 outliers among 100 measurements (1.00%)
  1 (1.00%) high mild
Benchmarking HashSet/u32/GxHash: Warming up for 3.0000 serror: bench failed, to rerun pass `--bench hashset`

Caused by:
  process didn't exit successfully: `/root/git/gxhash/target/release/deps/hashset-e0bfa844d705dd83 --bench` (signal: 4, SIGILL: illegal instruction)
     Running benches/ilp.rs (target/release/deps/ilp-18f7b97131886606)
Gnuplot not found, using plotters backend
baseline                time:   [134.34 µs 135.20 µs 136.28 µs]
Found 8 outliers among 100 measurements (8.00%)
  5 (5.00%) high mild
  3 (3.00%) high severe

unrolled                time:   [129.67 µs 132.18 µs 136.40 µs]
Found 12 outliers among 100 measurements (12.00%)
  2 (2.00%) high mild
  10 (10.00%) high severe

temp                    time:   [54.313 µs 55.820 µs 57.345 µs]
Found 1 outliers among 100 measurements (1.00%)
  1 (1.00%) high mild

laned                   time:   [46.377 µs 47.916 µs 49.764 µs]
Found 4 outliers among 100 measurements (4.00%)
  4 (4.00%) high mild

     Running benches/throughput/main.rs (target/release/deps/throughput-ce001a906bb8460b)
gxhash-avx2
error: bench failed, to rerun pass `--bench throughput`

Caused by:
  process didn't exit successfully: `/root/git/gxhash/target/release/deps/throughput-ce001a906bb8460b --bench` (signal: 4, SIGILL: illegal instruction)
     Running benches/throughput_criterion.rs (target/release/deps/throughput_criterion-c233dcb596180928)
Gnuplot not found, using plotters backend
Benchmarking all/gxhash-avx2/4: Warming up for 3.0000 serror: bench failed, to rerun pass `--bench throughput_criterion`

Caused by:
  process didn't exit successfully: `/root/git/gxhash/target/release/deps/throughput_criterion-c233dcb596180928 --bench` (signal: 4, SIGILL: illegal instruction)
error: 3 targets failed:
    `--bench hashset`
    `--bench throughput`
    `--bench throughput_criterion`
~/git/gxhash main                                                                                                                                                     1m 30s root@u2 13:43:20
❯ cargo bench --no-fail-fast -F=avx2
3tieto commented 9 months ago
❯ RUST_BACKTRACE=1 cargo test -Favx2 -- --nocapture
    Finished test [unoptimized + debuginfo] target(s) in 0.12s
     Running unittests src/lib.rs (target/debug/deps/gxhash-db5f87006ff816b7)

running 20 tests
error: test failed, to rerun pass `--lib`

Caused by:
  process didn't exit successfully: `/root/git/gxhash/target/debug/deps/gxhash-db5f87006ff816b7 --nocapture` (signal: 4, SIGILL: illegal instruction)
ogxd commented 9 months ago

Hi @3tieto,

On which branch are you? Are you on latest main?

This bug is supposed to be fixed since 2.3.0. There is even a test for it cargo test hasher_handles_empty_inputs --features avx2

If I run cargo bench --no-fail-fast -F=avx2 I do not have any issue on my end

3tieto commented 9 months ago

image

❯ git log -1
commit 8e109d97538ca95123ba73368fba18bb54d90005 (HEAD -> main, tag: 2.3.0, origin/main, origin/HEAD)
Author: Olivier Giniaux <oginiaux@gmail.com>
Date:   Sun Dec 10 10:53:04 2023 +0100

    Add Hasher write_x primitives (#42)

    * Add specialized write_u32

    * Fix hashset benchmark accurracy

    * Implement all types

    * Fix build

    * Fix avx2

    * Add mandatory 0 length check to avoid SIGSEGV and add test

    * Version 2.3.0

    ---------

    Co-authored-by: Olivier Giniaux <oginiaux@smartadserver.com>
❯ rm -rf target
ogxd commented 9 months ago

Is it running in a virtualized environment? (I see QEMU) Also, are other tests passing? (If you comment out hasher_handles_empty_inputs)

3tieto commented 9 months ago

i run in my vps https://contabo.com/

use rustc 1.76.0-nightly (21cce21d8 2023-12-11)

always crash image

3tieto commented 9 months ago

i create a tmp user for this error just ❯ ssh tmp@38.242.220.222 password PXeF5q53u9vo

cd ~/gxhash run test

ogxd commented 9 months ago

Thx for the SSH.
The issue is that your machine does not support VAES:

image

See on my machine I have this flag: image

The avx2 check is not sufficient. I thought avx2 implied vaes, but it seems it's not always the case. A check must be added in the code. https://github.com/ogxd/gxhash/blob/8e109d97538ca95123ba73368fba18bb54d90005/src/gxhash/platform/mod.rs#L5

I'll patch this by adding the vaes check, even though the flag will remain named avx2 (which is misleading now)

This should be enough given that there won't be avx2 feature flag anymore with the hybrid gxhash https://github.com/ogxd/gxhash/issues/34

xxaier commented 9 months ago

I look forward to the release of hybrid.

ogxd commented 9 months ago

Addressed with v3.0.0 (hybrid)