Skip to content

Conversation

@Polaris-911
Copy link
Contributor

While reviewing the Redis code, we discovered that optimizations for unaligned memory accesses are not enabled on RISC-V. After testing siphash separately, we found some performance improvements in this area and hope to add them.

The zicclsm extension, which includes unaligned memory accesses, is required on RISC-V, as specified in the RVA20U64 specification. GCC also provides the macro zicclsm to detect the zicclsm extension.

Supported versions: GCC 14.1.0 and above

Test data

environment information

[root@localhost root]# dmidecode -t processor | grep "Version"
        Version: SG2044
[root@localhost root]# uname -a
Linux localhost.localdomain 6.12.21-0.0.0.0.riscv64 #1 SMP Tue Apr  1 03:58:14 CST 2025 riscv64 riscv64 riscv64 GNU/Linux

Test Configuration​​
​​Test Iterations:​​ 10,000,000 hashes per run
Test Runs:​​ 10 consecutive runs

Improvement
6482733.40 --> 10732524.90 (​​+65.5%​)

Disable UNALIGNED_LE_CPU

[root@fedora-riscv root]# ./siphash_test_aligned
Running performance test (10 runs)...
Run 1: 6491958.63 hashes/sec
Run 2: 6487366.83 hashes/sec
Run 3: 6481576.94 hashes/sec
Run 4: 6484129.18 hashes/sec
Run 5: 6486451.34 hashes/sec
Run 6: 6476159.22 hashes/sec
Run 7: 6479075.32 hashes/sec
Run 8: 6476821.02 hashes/sec
Run 9: 6482822.05 hashes/sec
Run 10: 6480973.47 hashes/sec

Average performance: 6482733.40 hashes/sec

Enable UNALIGNED_LE_CPU

[root@fedora-riscv root]# ./siphash_test_unaligned
Running performance test (10 runs)...
Run 1: 10724141.20 hashes/sec
Run 2: 10736134.67 hashes/sec
Run 3: 10733149.45 hashes/sec
Run 4: 10732901.09 hashes/sec
Run 5: 10731710.56 hashes/sec
Run 6: 10734029.89 hashes/sec
Run 7: 10733342.07 hashes/sec
Run 8: 10732782.90 hashes/sec
Run 9: 10733797.15 hashes/sec
Run 10: 10733260.05 hashes/sec

Average performance: 10732524.90 hashes/sec

@snyk-io
Copy link

snyk-io bot commented Sep 9, 2025

🎉 Snyk checks have passed. No issues have been found so far.

security/snyk check is complete. No issues have been found. (View Details)

license/snyk check is complete. No issues have been found. (View Details)

@sundb sundb requested a review from fcostaoliveira September 9, 2025 07:36
@sundb sundb added this to Redis 8.4 Sep 9, 2025
@github-project-automation github-project-automation bot moved this to Todo in Redis 8.4 Sep 9, 2025
@sundb sundb added state:to-be-merged The PR should be merged soon, even if not yet ready, this is used so that it won't be forgotten and removed state:to-be-merged The PR should be merged soon, even if not yet ready, this is used so that it won't be forgotten labels Sep 11, 2025
@sundb sundb moved this from Todo to Awaits Merge in Redis 8.4 Sep 11, 2025
Copy link

@shahsb shahsb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@Polaris-911
Copy link
Contributor Author

Hi @fcostaoliveira ,please take a look at this PR when you have time. If you have any questions or suggestions for revisions, I will actively cooperate. Thank you.

@sundb sundb merged commit 791a5a7 into redis:unstable Oct 11, 2025
18 checks passed
@github-project-automation github-project-automation bot moved this from Awaits Merge to Done in Redis 8.4 Oct 11, 2025
@sundb
Copy link
Collaborator

sundb commented Oct 11, 2025

@Polaris-911 merged, thx.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants