From: Nick Terrell Date: Wed, 13 May 2020 00:51:16 +0000 (-0700) Subject: [greedy] Fix performance instability X-Git-Tag: v1.4.5^2~16^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=70c80e19e6c167a0d7eb30a8604fe70a8f81fb8d;p=thirdparty%2Fzstd.git [greedy] Fix performance instability --- diff --git a/lib/compress/zstd_lazy.c b/lib/compress/zstd_lazy.c index 67ed07cba..4cf5c88b5 100644 --- a/lib/compress/zstd_lazy.c +++ b/lib/compress/zstd_lazy.c @@ -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;