From 1093ccf7f60aafa0f98a2d92fe6ae1842092540f Mon Sep 17 00:00:00 2001 From: zhengziyang Date: Fri, 1 Aug 2025 10:56:39 +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 --- ...ance-FindMatchLength-to-Optimize-Sna.patch | 26 +++++++++++++++++++ snappy.spec | 7 ++++- 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 0001-Use-high-performance-FindMatchLength-to-Optimize-Sna.patch diff --git a/0001-Use-high-performance-FindMatchLength-to-Optimize-Sna.patch b/0001-Use-high-performance-FindMatchLength-to-Optimize-Sna.patch new file mode 100644 index 0000000..881a649 --- /dev/null +++ b/0001-Use-high-performance-FindMatchLength-to-Optimize-Sna.patch @@ -0,0 +1,26 @@ +From 47d6e8ed6837aabefb2f4d439f9eb4ebd899d453 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=E9=83=91=E7=B4=AB=E9=98=B310295048?= + +Date: Fri, 1 Aug 2025 15:38:44 +0800 +Subject: [PATCH] Use-high-performance-FindMatchLength-to-Optimize-Snappy + +--- + snappy-internal.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/snappy-internal.h b/snappy-internal.h +index 0923f39..6ad81b6 100644 +--- a/snappy-internal.h ++++ b/snappy-internal.h +@@ -172,7 +172,7 @@ char* CompressFragment(const char* input, + // Separate implementation for 64-bit, little-endian cpus. + #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..3300c92 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: 0001-Use-high-performance-FindMatchLength-to-Optimize-Sna.patch + BuildRequires: gcc-c++ make gtest-devel cmake @@ -69,6 +71,9 @@ make test %doc NEWS README.md %changelog +* Fri Aug 1 2025 liuqingtao -1.1.10-3 +- 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