From 051536ae06359496e59ae428fea83cd0b976f523 Mon Sep 17 00:00:00 2001 From: zhengziyang Date: Wed, 27 Aug 2025 16:11:14 +0800 Subject: [PATCH] This PR uses a high-performance FindMatchLength, improving compression speed by **~13.6%.**

Optimize Snappy 1.1.10 performance

lzbench 2.1 tests on silesia.tar (GCC 12.3.1, 64-bit Linux) show: | Compressor | Compress | Decompress | |-----------------------|-----------|------------| | Snappy 1.1.10 (Before) | 117 MB/s | 50.3 MB/s | | Snappy 1.1.10 (After) | 133 MB/s | 54.3 MB/s |

Snappy 1.1.10 unittest

``` + cd snappy-1.1.10 + make test Running tests... /usr/bin/ctest --force-new-ctest-process Test project /home/zzy/rpmbuild/BUILD/snappy-1.1.10 Start 1: snappy_unittest 1/1 Test #1: snappy_unittest .................. Passed 377.91 sec 100% tests passed, 0 tests failed out of 1 Total Test time (real) = 378.04 sec ``` Signed-off-by: liuqingtao (cherry picked from commit 937529e2b232e3ad743cb08f2f5aa14977b45f8f) --- ...ng-compress-speed--upstream-accepted.patch | 30 +++++++++++++++++++ snappy.spec | 8 ++++- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 optimized-RV-FindMatchLength-improving-compress-speed--upstream-accepted.patch diff --git a/optimized-RV-FindMatchLength-improving-compress-speed--upstream-accepted.patch b/optimized-RV-FindMatchLength-improving-compress-speed--upstream-accepted.patch new file mode 100644 index 0000000..73a70ae --- /dev/null +++ b/optimized-RV-FindMatchLength-improving-compress-speed--upstream-accepted.patch @@ -0,0 +1,30 @@ +From d89c9def26081f01ac55aefdb349e44b88023c35 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=E9=83=91=E7=B4=AB=E9=98=B310295048?= + +Date: Wed, 27 Aug 2025 09:11:06 +0800 +Subject: [PATCH] + optimized-RV-FindMatchLength-improving-compress-speed--upstream-accepted + +--- + snappy-internal.h | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/snappy-internal.h b/snappy-internal.h +index 0923f39..4414e17 100644 +--- a/snappy-internal.h ++++ b/snappy-internal.h +@@ -170,9 +170,10 @@ char* CompressFragment(const char* input, + // loading from s2 + n. + // + // Separate implementation for 64-bit, little-endian cpus. ++// riscv and little-endian cpu choose this routinue can be done faster too + #if !SNAPPY_IS_BIG_ENDIAN && \ + (defined(__x86_64__) || defined(_M_X64) || defined(ARCH_PPC) || \ +- defined(ARCH_ARM)) ++ defined(ARCH_ARM) || defined(__riscv)) + static inline std::pair FindMatchLength(const char* s1, + const char* s2, + const char* s2_limit, +-- +2.21.0.windows.1 + diff --git a/snappy.spec b/snappy.spec index b45de6a..cc889dd 100644 --- a/snappy.spec +++ b/snappy.spec @@ -1,6 +1,6 @@ Name: snappy Version: 1.1.10 -Release: 2 +Release: 3 Summary: A fast compressor/decompressor License: BSD URL: https://github.com/google/snappy @@ -9,6 +9,8 @@ Source1: snappy.pc Patch0: remove-dependency-on-google-benchmark-and-gmock.patch Patch2: add-option-to-enable-rtti-set-default-to-current-ben.patch +Patch3: optimized-RV-FindMatchLength-improving-compress-speed--upstream-accepted.patch + BuildRequires: gcc-c++ make gtest-devel cmake @@ -69,6 +71,10 @@ make test %doc NEWS README.md %changelog +* Fri Aug 1 2025 liuqingtao -1.1.10-3 +- optimized-RV-FindMatchLength-improving-compress-speed--upstream-accepted +- DESC:Use-high-performance-FindMatchLength-to-Optimize for RV + * Fri Jan 12 2024 zhoupengcheng -1.1.10-2 - Build with C++14 instead of C++11; gtest 1.13.0 requires it -- Gitee