diff --git a/0004-enable-unaligned-access-optimizations-for-RISC-V.patch b/0004-enable-unaligned-access-optimizations-for-RISC-V.patch new file mode 100644 index 0000000000000000000000000000000000000000..9cea91ddfd486a16eef9dcda1f4e7a7b81501e91 --- /dev/null +++ b/0004-enable-unaligned-access-optimizations-for-RISC-V.patch @@ -0,0 +1,83 @@ +From 3b7f83faf6f597cfd14a0d2ff43a74450604d586 Mon Sep 17 00:00:00 2001 +From: huangshangcheng +Date: Thu, 18 Sep 2025 19:47:49 +0800 +Subject: [PATCH] enable unaligned access optimizations for RISC-V with Zicclsm +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 +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 + +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 + +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 + +Signed-off-by: liuqingtao + +--- + src/siphash.c | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +diff --git a/src/siphash.c b/src/siphash.c +index 2713d89..721b34b 100644 +--- a/src/siphash.c ++++ b/src/siphash.c +@@ -67,9 +67,12 @@ int siptlw(int c) { + + /* Test of the CPU is Little Endian and supports not aligned accesses. + * Two interesting conditions to speedup the function that happen to be +- * in most of x86 servers. */ ++ * in most of x86 servers. ++ * Additionally supports RISC-V CPUs implementing the Zicclsm extension ++ * for unaligned access. */ + #if defined(__X86_64__) || defined(__x86_64__) || defined (__i386__) \ +- || defined (__aarch64__) || defined (__arm64__) ++ || defined (__aarch64__) || defined (__arm64__) \ ++ || (defined(__riscv) && defined(__riscv_zicclsm)) + #define UNALIGNED_LE_CPU + #endif + +-- +2.45.2.windows.1 + diff --git a/redis.spec b/redis.spec index 7624d0d36f050441111417ff4e17ed4f55af5fc5..d37e20906a5e68663d06314aff7b5f90d7ac8554 100644 --- a/redis.spec +++ b/redis.spec @@ -7,7 +7,7 @@ Name: redis Version: 7.2.10 -Release: 1 +Release: 2 Summary: A persistent key-value database # redis, hiredis: BSD-3-Clause # hdrhistogram, jemalloc, lzf, linenoise: BSD-2-Clause @@ -26,6 +26,7 @@ Source6: https://github.com/%{name}/%{name}-doc/archive/%{doc_commit}/ Patch0001: 0001-1st-man-pageis-for-redis-cli-redis-benchmark-redis-c.patch Patch0002: 0002-add-sw_64-support.patch Patch0003: CVE-2025-49112.patch +Patch0004: 0004-enable-unaligned-access-optimizations-for-RISC-V.patch BuildRequires: systemd BuildRequires: systemd-devel @@ -53,6 +54,7 @@ mv ../%{name}-doc-%{doc_commit} doc %patch -P0001 -p1 %patch -P0002 -p1 %patch -P0003 -p1 +%patch -P0004 -p1 mv deps/lua/COPYRIGHT COPYRIGHT-lua mv deps/jemalloc/COPYING COPYING-jemalloc @@ -196,6 +198,9 @@ exit 0 %{_docdir}/%{name} %changelog +* Thu Sep 18 2025 Liu Qingtao - 7.2.10-2 +- Added support for unaligned access optimizations on RISC-V with Zicclsm extension. + * Thu Jul 10 2025 wangkai <13474090681@163.com> - 7.2.10-1 - Update to 7.2.10 - Fix CVE-2025-32023 CVE-2025-48367