GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — refactor riscv-v implementation. by BoBoDai · Pull Request #1069 · Cyan4973/xxHash

Conversation

@BoBoDai

@BoBoDai BoBoDai commented Sep 9, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

This Pull Request aims to refactor based on the previously closed PR (#1043). The focus is on optimizing through Riscv Vector Extensions (RVV), resulting in shorter and more readable code while also bringing about partial performance improvements.

All codes are tested on a RISC-V server driven by the Sophgo SG2044 processor, which supports native RVV 1.0.

I also noticed a point mentioned in PR (#1043), which is that using the -O2 option for optimization yields better results than using the -O3 option. I have reproduced this observation on my device. The following test data will reflect this point.

The benchmark test after refactoring
use command :CFLAGS="-march=rv64gcv -O2 -DXXH_FORCE_MEMORY_ACCESS=0" make check

OK. (passes 49948 tests)
5ffb01494ce73724  stdin
5ffb01494ce73724  xxhash.c
79bb1b74bda34a49  xxhash.h
xxhsum 0.8.3 by Yann Collet
compiled as 64-bit riscv little endian with GCC 15.1.0
Sample of 100 KB...
 1#XXH32                         :     102400 ->    23130 it/s ( 2258.8 MB/s)
 3#XXH64                         :     102400 ->    48562 it/s ( 4742.4 MB/s)
 5#XXH3_64b                      :     102400 ->    25565 it/s ( 2496.5 MB/s)
11#XXH128                        :     102400 ->    25351 it/s ( 2475.7 MB/s)
xxhsum 0.8.3 by Yann Collet
compiled as 64-bit riscv little endian with GCC 15.1.0
Sample of 100 KB...
 1#XXH32                         :     102400 ->    23909 it/s ( 2334.9 MB/s)
 2#XXH32 unaligned               :     102400 ->    13190 it/s ( 1288.1 MB/s)
 3#XXH64                         :     102400 ->    50000 it/s ( 4882.8 MB/s)
 4#XXH64 unaligned               :     102400 ->    17078 it/s ( 1667.8 MB/s)
 5#XXH3_64b                      :     102400 ->    25705 it/s ( 2510.3 MB/s)
 6#XXH3_64b unaligned            :     102400 ->    24144 it/s ( 2357.9 MB/s)
 7#XXH3_64b w/seed               :     102400 ->    24976 it/s ( 2439.0 MB/s)
 8#XXH3_64b w/seed unaligned     :     102400 ->    22667 it/s ( 2213.6 MB/s)
 9#XXH3_64b w/secret             :     102400 ->    24489 it/s ( 2391.5 MB/s)
10#XXH3_64b w/secret unaligned   :     102400 ->    22677 it/s ( 2214.6 MB/s)
11#XXH128                        :     102400 ->    25667 it/s ( 2506.5 MB/s)
12#XXH128 unaligned              :     102400 ->    24077 it/s ( 2351.2 MB/s)
13#XXH128 w/seed                 :     102400 ->    25085 it/s ( 2449.7 MB/s)
14#XXH128 w/seed unaligned       :     102400 ->    22727 it/s ( 2219.5 MB/s)
15#XXH128 w/secret               :     102400 ->    24742 it/s ( 2416.2 MB/s)
16#XXH128 w/secret unaligned     :     102400 ->    23058 it/s ( 2251.8 MB/s)
17#XXH32_stream                  :     102400 ->    26992 it/s ( 2635.9 MB/s)
18#XXH32_stream unaligned        :     102400 ->       90 it/s (    8.8 MB/s)
19#XXH64_stream                  :     102400 ->    53618 it/s ( 5236.1 MB/s)
20#XXH64_stream unaligned        :     102400 ->      108 it/s (   10.6 MB/s)
21#XXH3_stream                   :     102400 ->    25705 it/s ( 2510.3 MB/s)
22#XXH3_stream unaligned         :     102400 ->    24161 it/s ( 2359.5 MB/s)
23#XXH3_stream w/seed            :     102400 ->    25763 it/s ( 2515.9 MB/s)
24#XXH3_stream w/seed unaligned  :     102400 ->    24184 it/s ( 2361.7 MB/s)
25#XXH128_stream                 :     102400 ->    25756 it/s ( 2515.3 MB/s)
26#XXH128_stream unaligned       :     102400 ->    24304 it/s ( 2373.4 MB/s)
27#XXH128_stream w/seed          :     102400 ->    25641 it/s ( 2504.0 MB/s)
28#XXH128_stream w/seed unaligne :     102400 ->    24167 it/s ( 2360.1 MB/s)
xxhsum 0.8.3 by Yann Collet
compiled as 64-bit riscv little endian with GCC 15.1.0
Sample of 100 KB...
 1#XXH32                         :     102400 ->    23115 it/s ( 2257.3 MB/s)
 2#XXH32 unaligned               :     102400 ->    13106 it/s ( 1279.9 MB/s)
 3#XXH64                         :     102400 ->    49377 it/s ( 4822.0 MB/s)
xxhsum 0.8.3 by Yann Collet
compiled as 64-bit riscv little endian with GCC 15.1.0
 1#XXH32                         :       1855 ->  1331919 it/s ( 2356.3 MB/s)
 3#XXH64                         :       1855 ->  2109783 it/s ( 3732.3 MB/s)
 5#XXH3_64b                      :       1855 ->  1275107 it/s ( 2255.7 MB/s)
11#XXH128                        :       1855 ->  1255556 it/s ( 2221.2 MB/s)
623b23d3  xxhash.c
7615c59c2d746e27e873a692555aca2b  xxhash.c
XXH3_e873a692555aca2b  xxhash.c
Wrong parameters

The benchmark test before refactoring
use command :CFLAGS="-march=rv64gcv -O2 -DXXH_FORCE_MEMORY_ACCESS=0" make check

OK. (passes 49948 tests)
5ffb01494ce73724  stdin
5ffb01494ce73724  xxhash.c
f635324900df9608  xxhash.h
xxhsum 0.8.3 by Yann Collet
compiled as 64-bit riscv little endian with GCC 15.1.0
Sample of 100 KB...
 1#XXH32                         :     102400 ->    23516 it/s ( 2296.5 MB/s)
 3#XXH64                         :     102400 ->    45215 it/s ( 4415.5 MB/s)
 5#XXH3_64b                      :     102400 ->    24004 it/s ( 2344.1 MB/s)
11#XXH128                        :     102400 ->    24454 it/s ( 2388.1 MB/s)
xxhsum 0.8.3 by Yann Collet
compiled as 64-bit riscv little endian with GCC 15.1.0
Sample of 100 KB...
 1#XXH32                         :     102400 ->    23478 it/s ( 2292.8 MB/s)
 2#XXH32 unaligned               :     102400 ->    12432 it/s ( 1214.1 MB/s)
 3#XXH64                         :     102400 ->    45859 it/s ( 4478.4 MB/s)
 4#XXH64 unaligned               :     102400 ->    17047 it/s ( 1664.8 MB/s)
 5#XXH3_64b                      :     102400 ->    23261 it/s ( 2271.6 MB/s)
 6#XXH3_64b unaligned            :     102400 ->    22343 it/s ( 2181.9 MB/s)
 7#XXH3_64b w/seed               :     102400 ->    23931 it/s ( 2337.0 MB/s)
 8#XXH3_64b w/seed unaligned     :     102400 ->    22122 it/s ( 2160.4 MB/s)
 9#XXH3_64b w/secret             :     102400 ->    22065 it/s ( 2154.8 MB/s)
10#XXH3_64b w/secret unaligned   :     102400 ->    20280 it/s ( 1980.4 MB/s)
11#XXH128                        :     102400 ->    24688 it/s ( 2411.0 MB/s)
12#XXH128 unaligned              :     102400 ->    22155 it/s ( 2163.6 MB/s)
13#XXH128 w/seed                 :     102400 ->    23903 it/s ( 2334.3 MB/s)
14#XXH128 w/seed unaligned       :     102400 ->    22578 it/s ( 2204.9 MB/s)
15#XXH128 w/secret               :     102400 ->    22747 it/s ( 2221.4 MB/s)
16#XXH128 w/secret unaligned     :     102400 ->    21675 it/s ( 2116.7 MB/s)
17#XXH32_stream                  :     102400 ->    25699 it/s ( 2509.6 MB/s)
18#XXH32_stream unaligned        :     102400 ->       90 it/s (    8.8 MB/s)
19#XXH64_stream                  :     102400 ->    47641 it/s ( 4652.4 MB/s)
20#XXH64_stream unaligned        :     102400 ->      107 it/s (   10.5 MB/s)
21#XXH3_stream                   :     102400 ->    22652 it/s ( 2212.1 MB/s)
22#XXH3_stream unaligned         :     102400 ->    20918 it/s ( 2042.8 MB/s)
23#XXH3_stream w/seed            :     102400 ->    22996 it/s ( 2245.7 MB/s)
24#XXH3_stream w/seed unaligned  :     102400 ->    21220 it/s ( 2072.2 MB/s)
25#XXH128_stream                 :     102400 ->    23261 it/s ( 2271.6 MB/s)
26#XXH128_stream unaligned       :     102400 ->    21490 it/s ( 2098.6 MB/s)
27#XXH128_stream w/seed          :     102400 ->    22304 it/s ( 2178.1 MB/s)
28#XXH128_stream w/seed unaligne :     102400 ->    21365 it/s ( 2086.4 MB/s)
xxhsum 0.8.3 by Yann Collet
compiled as 64-bit riscv little endian with GCC 15.1.0
Sample of 100 KB...
 1#XXH32                         :     102400 ->    23172 it/s ( 2262.9 MB/s)
 2#XXH32 unaligned               :     102400 ->    12595 it/s ( 1230.0 MB/s)
 3#XXH64                         :     102400 ->    46230 it/s ( 4514.6 MB/s)
xxhsum 0.8.3 by Yann Collet
compiled as 64-bit riscv little endian with GCC 15.1.0
 1#XXH32                         :       1855 ->  1331291 it/s ( 2355.1 MB/s)
 3#XXH64                         :       1855 ->  1980372 it/s ( 3503.4 MB/s)
 5#XXH3_64b                      :       1855 ->  1275107 it/s ( 2255.7 MB/s)
11#XXH128                        :       1855 ->  1234433 it/s ( 2183.8 MB/s)
623b23d3  xxhash.c
7615c59c2d746e27e873a692555aca2b  xxhash.c
XXH3_e873a692555aca2b  xxhash.c
Wrong parameters

By comparing the two sets of data, we can observe an overall performance improvement of 8% to 9%.

The benchmark test after refactoring and build by -O3.
use command :CFLAGS="-march=rv64gcv -O3 -DXXH_FORCE_MEMORY_ACCESS=0" make check

OK. (passes 49948 tests)
5ffb01494ce73724  stdin
5ffb01494ce73724  xxhash.c
79bb1b74bda34a49  xxhash.h
xxhsum 0.8.3 by Yann Collet
compiled as 64-bit riscv little endian with GCC 15.1.0
Sample of 100 KB...
 1#XXH32                         :     102400 ->    21409 it/s ( 2090.7 MB/s)
 3#XXH64                         :     102400 ->    46355 it/s ( 4526.8 MB/s)
 5#XXH3_64b                      :     102400 ->    20854 it/s ( 2036.6 MB/s)
11#XXH128                        :     102400 ->    20812 it/s ( 2032.4 MB/s)
xxhsum 0.8.3 by Yann Collet
compiled as 64-bit riscv little endian with GCC 15.1.0
Sample of 100 KB...
 1#XXH32                         :     102400 ->    21334 it/s ( 2083.4 MB/s)
 2#XXH32 unaligned               :     102400 ->    12395 it/s ( 1210.4 MB/s)
 3#XXH64                         :     102400 ->    43626 it/s ( 4260.3 MB/s)
 4#XXH64 unaligned               :     102400 ->    17000 it/s ( 1660.1 MB/s)
 5#XXH3_64b                      :     102400 ->    20555 it/s ( 2007.3 MB/s)
 6#XXH3_64b unaligned            :     102400 ->    16971 it/s ( 1657.4 MB/s)
 7#XXH3_64b w/seed               :     102400 ->    20420 it/s ( 1994.2 MB/s)
 8#XXH3_64b w/seed unaligned     :     102400 ->    15927 it/s ( 1555.4 MB/s)
 9#XXH3_64b w/secret             :     102400 ->    18748 it/s ( 1830.8 MB/s)
10#XXH3_64b w/secret unaligned   :     102400 ->    14904 it/s ( 1455.4 MB/s)
11#XXH128                        :     102400 ->    18986 it/s ( 1854.1 MB/s)
12#XXH128 unaligned              :     102400 ->    14442 it/s ( 1410.3 MB/s)
13#XXH128 w/seed                 :     102400 ->    19880 it/s ( 1941.4 MB/s)
14#XXH128 w/seed unaligned       :     102400 ->    15152 it/s ( 1479.6 MB/s)
15#XXH128 w/secret               :     102400 ->    17885 it/s ( 1746.6 MB/s)
16#XXH128 w/secret unaligned     :     102400 ->    14679 it/s ( 1433.5 MB/s)
17#XXH32_stream                  :     102400 ->    27006 it/s ( 2637.3 MB/s)
18#XXH32_stream unaligned        :     102400 ->       90 it/s (    8.8 MB/s)
19#XXH64_stream                  :     102400 ->    52073 it/s ( 5085.2 MB/s)
20#XXH64_stream unaligned        :     102400 ->      108 it/s (   10.6 MB/s)
21#XXH3_stream                   :     102400 ->    15479 it/s ( 1511.7 MB/s)
22#XXH3_stream unaligned         :     102400 ->    11520 it/s ( 1125.0 MB/s)
23#XXH3_stream w/seed            :     102400 ->    15620 it/s ( 1525.4 MB/s)
24#XXH3_stream w/seed unaligned  :     102400 ->    12792 it/s ( 1249.2 MB/s)
25#XXH128_stream                 :     102400 ->    17577 it/s ( 1716.5 MB/s)
26#XXH128_stream unaligned       :     102400 ->    13146 it/s ( 1283.8 MB/s)
27#XXH128_stream w/seed          :     102400 ->    16753 it/s ( 1636.1 MB/s)
28#XXH128_stream w/seed unaligne :     102400 ->    14349 it/s ( 1401.3 MB/s)
xxhsum 0.8.3 by Yann Collet
compiled as 64-bit riscv little endian with GCC 15.1.0
Sample of 100 KB...
 1#XXH32                         :     102400 ->    21038 it/s ( 2054.5 MB/s)
 2#XXH32 unaligned               :     102400 ->    12402 it/s ( 1211.1 MB/s)
 3#XXH64                         :     102400 ->    46147 it/s ( 4506.5 MB/s)
xxhsum 0.8.3 by Yann Collet
compiled as 64-bit riscv little endian with GCC 15.1.0
 1#XXH32                         :       1855 ->  1133855 it/s ( 2005.9 MB/s)
 3#XXH64                         :       1855 ->  2293950 it/s ( 4058.1 MB/s)
 5#XXH3_64b                      :       1855 ->  1432193 it/s ( 2533.6 MB/s)
11#XXH128                        :       1855 ->  1364075 it/s ( 2413.1 MB/s)
623b23d3  xxhash.c
7615c59c2d746e27e873a692555aca2b  xxhash.c
XXH3_e873a692555aca2b  xxhash.c
Wrong parameters

Compared to the first set of data, we can notice about 25% overall performance degradation.

I have also noticed that there is a performance penalty in tests XXH32_stream unaligned and XXH64_stream, but this is not a problem introduced by the refactoring. I am more than willing to try and fix this bug.

Co-authored-by: gong-flying [email protected]

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Cyan4973 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@BoBoDai BoBoDai mentioned this pull request Sep 9, 2025
enhance riscv-v implementation performance. #1070
Merged
Cyan4973
Cyan4973 reviewed Sep 9, 2025
View reviewed changes
Comment thread xxhash.h Resolved

Uh oh!

There was an error while loading. Please reload this page.

Cyan4973
Cyan4973 reviewed Sep 9, 2025
View reviewed changes
Comment thread xxhash.h Resolved

Uh oh!

There was an error while loading. Please reload this page.

@Cyan4973

Cyan4973 commented Sep 9, 2025

Copy link
Copy Markdown
Owner

This is a welcomed simplification

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Cyan4973
Cyan4973 reviewed Sep 9, 2025
View reviewed changes
Comment thread xxhash.h Resolved

Uh oh!

There was an error while loading. Please reload this page.

@BoBoDai
refactor riscv-v implementation.
fb07846
Co-authored-by: gong-flying <[email protected]>
@Cyan4973 Cyan4973 self-assigned this Sep 9, 2025
Cyan4973
Cyan4973 approved these changes Sep 9, 2025
View reviewed changes
@Cyan4973
Cyan4973 merged commit e8a6d64 into Cyan4973:dev Sep 9, 2025
@BoBoDai
BoBoDai deleted the refactor_rvv_implementation branch September 9, 2025 22:35
@ixgbe ixgbe mentioned this pull request Jan 6, 2026
gguf-hash: add RVV tensor hashing using xxh3 ggml-org/llama.cpp#18576
Closed
@luhenry luhenry mentioned this pull request Apr 9, 2026
Add linux-riscv64 binary yawkat/lz4-java#46
Merged
@BrewTestBot BrewTestBot mentioned this pull request Sep 19, 2026
xxhash 0.8.4 Homebrew/homebrew-core#312146
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@Cyan4973 Cyan4973 Cyan4973 approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@Cyan4973 Cyan4973

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@BoBoDai @Cyan4973
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.