]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
[linux-kernel] Don't inline function in zstd_opt.c
authorNick Terrell <terrelln@fb.com>
Tue, 16 Nov 2021 00:57:00 +0000 (16:57 -0800)
committerNick Terrell <terrelln@fb.com>
Tue, 16 Nov 2021 04:37:58 +0000 (20:37 -0800)
The optimal parser is unlikely to be used in the linux kernel in
practice. There is no reason these functions should be force inlined,
since we aren't gaining anything, and are losing build size.

| Compiler | Before (Bytes) | After (Bytes) | Delta (Bytes) |
|----------|----------------|---------------|---------------|
| gcc-11   |        1142090 |        952754 |       -189336 |
| clang-12 |        1228402 |        976290 |       -252112 |

This is a temporary solution pending the resolution of Issue #2862 in
the `dev` branch.

contrib/linux-kernel/Makefile
contrib/linux-kernel/test/macro-test.sh
lib/compress/zstd_opt.c

index fbd4a4ab1e44ceb351f2f363f5fe1a553d9269f4..b1c7f6f72e5681fc186eca42216af770ae96ea34 100644 (file)
@@ -39,7 +39,6 @@ libzstd:
                -DZSTD_ADDRESS_SANITIZER=0 \
                -DZSTD_MEMORY_SANITIZER=0 \
                -DZSTD_COMPRESS_HEAPMODE=1 \
-               -UZSTD_NO_INLINE \
                -UNO_PREFETCH \
                -U__cplusplus \
                -UZSTD_DLL_EXPORT \
@@ -53,7 +52,8 @@ libzstd:
                -RZSTD_FALLTHROUGH=fallthrough \
                -DZSTD_HAVE_WEAK_SYMBOLS=0 \
                -DZSTD_TRACE=0 \
-               -DZSTD_NO_TRACE
+               -DZSTD_NO_TRACE \
+               -DZSTD_LINUX_KERNEL
        mv linux/lib/zstd/zstd.h linux/include/linux/zstd_lib.h
        mv linux/lib/zstd/common/zstd_errors.h linux/include/linux/
        cp linux_zstd.h linux/include/linux/zstd.h
index c688ac03b4770018f6c781a9e65fe97ff6a0d4dc..3363cfcdfb35084dcf2024d99494a908eeaa3f5b 100755 (executable)
@@ -36,7 +36,6 @@ test_not_present "ZSTD_NO_INTRINSICS"
 test_not_present "ZSTD_NO_UNUSED_FUNCTIONS"
 test_not_present "ZSTD_LEGACY_SUPPORT"
 test_not_present "STATIC_BMI2"
-test_not_present "ZSTD_NO_INLINE"
 test_not_present "ZSTD_DLL_EXPORT"
 test_not_present "ZSTD_DLL_IMPORT"
 test_not_present "__ICCARM__"
index d9fbfef1f2576073bb3892d125779ab696cd5d0c..c1b311effc6ee5d4dd73a85977a1e8d2c7c39a1a 100644 (file)
@@ -8,6 +8,20 @@
  * You may select, at your option, one of the above-listed licenses.
  */
 
+/**
+ * Disable inlining for the optimal parser for the kernel build.
+ * It is unlikely to be used in the kernel, and where it is used
+ * latency shouldn't matter because it is very slow to begin with.
+ * We prefer a ~180KB binary size win over faster optimal parsing.
+ *
+ * TODO(https://github.com/facebook/zstd/issues/2862):
+ * Improve the code size of the optimal parser in general, so we
+ * don't need this hack for the kernel build.
+ */
+#ifdef ZSTD_LINUX_KERNEL
+#define ZSTD_NO_INLINE 1
+#endif
+
 #include "zstd_compress_internal.h"
 #include "hist.h"
 #include "zstd_opt.h"
@@ -894,7 +908,7 @@ static void ZSTD_optLdm_processMatchCandidate(ZSTD_optLdm_t* optLdm, ZSTD_match_
              */
             U32 posOvershoot = currPosInBlock - optLdm->endPosInBlock;
             ZSTD_optLdm_skipRawSeqStoreBytes(&optLdm->seqStore, posOvershoot);
-        } 
+        }
         ZSTD_opt_getNextMatchAndUpdateSeqStore(optLdm, currPosInBlock, remainingBytes);
     }
     ZSTD_optLdm_maybeAddMatch(matches, nbMatches, optLdm, currPosInBlock);