]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
[greedy] Fix performance instability 2134/head
authorNick Terrell <terrelln@fb.com>
Wed, 13 May 2020 00:51:16 +0000 (17:51 -0700)
committerNick Terrell <terrelln@fb.com>
Wed, 13 May 2020 00:51:16 +0000 (17:51 -0700)
lib/compress/zstd_lazy.c

index 67ed07cba7a0829d70aabcf6ba6b787c2338af55..4cf5c88b5325c737c7a0142b0ba740d6e696c761 100644 (file)
@@ -681,6 +681,12 @@ ZSTD_compressBlock_lazy_generic(
     }
 
     /* Match Loop */
+#if defined(__GNUC__) && defined(__x86_64__)
+    /* I've measured random a 5% speed loss on levels 5 & 6 (greedy) when the
+     * code alignment is perturbed. To fix the instability align the loop on 32-bytes.
+     */
+    __asm__(".p2align 5");
+#endif
     while (ip < ilimit) {
         size_t matchLength=0;
         size_t offset=0;
@@ -952,6 +958,12 @@ size_t ZSTD_compressBlock_lazy_extDict_generic(
     ip += (ip == prefixStart);
 
     /* Match Loop */
+#if defined(__GNUC__) && defined(__x86_64__)
+    /* I've measured random a 5% speed loss on levels 5 & 6 (greedy) when the
+     * code alignment is perturbed. To fix the instability align the loop on 32-bytes.
+     */
+    __asm__(".p2align 5");
+#endif
     while (ip < ilimit) {
         size_t matchLength=0;
         size_t offset=0;