2017-08-18 16:52:05 -07:00
|
|
|
/*
|
2022-12-20 12:49:47 -05:00
|
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
2016-08-30 10:04:33 -07:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
2017-08-18 16:52:05 -07:00
|
|
|
* This source code is licensed under both the BSD-style license (found in the
|
|
|
|
* LICENSE file in the root directory of this source tree) and the GPLv2 (found
|
|
|
|
* in the COPYING file in the root directory of this source tree).
|
2017-09-08 00:09:23 -07:00
|
|
|
* You may select, at your option, one of the above-listed licenses.
|
2016-08-30 10:04:33 -07:00
|
|
|
*/
|
2015-10-29 16:49:43 +01:00
|
|
|
|
|
|
|
#ifndef ZSTD_CCOMMON_H_MODULE
|
|
|
|
#define ZSTD_CCOMMON_H_MODULE
|
|
|
|
|
2017-11-07 15:27:06 -08:00
|
|
|
/* this module contains definitions which must be identical
|
|
|
|
* across compression, decompression and dictBuilder.
|
|
|
|
* It also contains a few functions useful to at least 2 of them
|
|
|
|
* and which benefit from being inlined */
|
2016-09-06 15:05:19 +02:00
|
|
|
|
2016-02-12 00:07:30 +01:00
|
|
|
/*-*************************************
|
2016-02-04 15:28:14 +01:00
|
|
|
* Dependencies
|
2015-10-29 16:49:43 +01:00
|
|
|
***************************************/
|
2020-03-28 00:11:50 +08:00
|
|
|
#include "compiler.h"
|
2021-11-30 17:43:28 -08:00
|
|
|
#include "cpu.h"
|
2020-03-28 00:11:50 +08:00
|
|
|
#include "mem.h"
|
2018-06-13 14:59:26 -04:00
|
|
|
#include "debug.h" /* assert, DEBUGLOG, RAWLOG, g_debuglevel */
|
2016-01-21 15:38:47 +01:00
|
|
|
#include "error_private.h"
|
2016-06-04 19:47:02 +02:00
|
|
|
#define ZSTD_STATIC_LINKING_ONLY
|
2020-05-01 16:07:57 -04:00
|
|
|
#include "../zstd.h"
|
2017-07-12 19:08:24 -07:00
|
|
|
#define FSE_STATIC_LINKING_ONLY
|
|
|
|
#include "fse.h"
|
|
|
|
#include "huf.h"
|
2017-03-01 11:33:25 -08:00
|
|
|
#ifndef XXH_STATIC_LINKING_ONLY
|
2017-06-02 18:20:48 -07:00
|
|
|
# define XXH_STATIC_LINKING_ONLY /* XXH64_state_t */
|
|
|
|
#endif
|
|
|
|
#include "xxhash.h" /* XXH_reset, update, digest */
|
2021-03-15 14:46:26 -07:00
|
|
|
#ifndef ZSTD_NO_TRACE
|
|
|
|
# include "zstd_trace.h"
|
|
|
|
#else
|
|
|
|
# define ZSTD_TRACE 0
|
|
|
|
#endif
|
2017-06-02 18:20:48 -07:00
|
|
|
|
2017-08-24 18:09:50 -07:00
|
|
|
#if defined (__cplusplus)
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2018-06-13 14:59:26 -04:00
|
|
|
/* ---- static assert (debug) --- */
|
|
|
|
#define ZSTD_STATIC_ASSERT(c) DEBUG_STATIC_ASSERT(c)
|
2018-10-23 17:25:49 -07:00
|
|
|
#define ZSTD_isError ERR_isError /* for inlining */
|
|
|
|
#define FSE_isError ERR_isError
|
|
|
|
#define HUF_isError ERR_isError
|
2015-10-29 16:49:43 +01:00
|
|
|
|
|
|
|
|
2016-02-12 00:07:30 +01:00
|
|
|
/*-*************************************
|
2016-09-06 15:36:19 +02:00
|
|
|
* shared macros
|
2015-11-11 21:38:21 +01:00
|
|
|
***************************************/
|
2017-04-17 17:57:35 -07:00
|
|
|
#undef MIN
|
|
|
|
#undef MAX
|
2015-10-31 12:57:14 +01:00
|
|
|
#define MIN(a,b) ((a)<(b) ? (a) : (b))
|
2015-11-11 21:38:21 +01:00
|
|
|
#define MAX(a,b) ((a)>(b) ? (a) : (b))
|
2021-10-26 08:21:31 -07:00
|
|
|
#define BOUNDED(min,val,max) (MAX(min,MIN(val,max)))
|
2019-01-28 17:16:32 -05:00
|
|
|
|
2015-10-29 16:49:43 +01:00
|
|
|
|
2016-02-12 00:07:30 +01:00
|
|
|
/*-*************************************
|
2015-11-11 21:38:21 +01:00
|
|
|
* Common constants
|
|
|
|
***************************************/
|
2016-03-02 15:56:24 +01:00
|
|
|
#define ZSTD_OPT_NUM (1<<12)
|
2015-11-25 14:42:45 +01:00
|
|
|
|
2016-08-10 15:01:53 +02:00
|
|
|
#define ZSTD_REP_NUM 3 /* number of repcodes */
|
2020-09-23 12:58:38 -07:00
|
|
|
static UNUSED_ATTR const U32 repStartValue[ZSTD_REP_NUM] = { 1, 4, 8 };
|
2015-11-25 14:42:45 +01:00
|
|
|
|
2015-11-11 21:38:21 +01:00
|
|
|
#define KB *(1 <<10)
|
|
|
|
#define MB *(1 <<20)
|
|
|
|
#define GB *(1U<<30)
|
2015-10-29 16:49:43 +01:00
|
|
|
|
2015-11-11 21:38:21 +01:00
|
|
|
#define BIT7 128
|
|
|
|
#define BIT6 64
|
|
|
|
#define BIT5 32
|
|
|
|
#define BIT4 16
|
|
|
|
#define BIT1 2
|
|
|
|
#define BIT0 1
|
2015-10-29 16:49:43 +01:00
|
|
|
|
2016-06-06 00:26:38 +02:00
|
|
|
#define ZSTD_WINDOWLOG_ABSOLUTEMIN 10
|
2020-09-23 12:58:38 -07:00
|
|
|
static UNUSED_ATTR const size_t ZSTD_fcs_fieldSize[4] = { 0, 2, 4, 8 };
|
|
|
|
static UNUSED_ATTR const size_t ZSTD_did_fieldSize[4] = { 0, 1, 2, 4 };
|
2016-03-19 15:11:42 +01:00
|
|
|
|
2018-08-14 12:56:21 -07:00
|
|
|
#define ZSTD_FRAMEIDSIZE 4 /* magic number size */
|
2017-09-25 15:25:07 -07:00
|
|
|
|
2016-06-04 20:17:38 +02:00
|
|
|
#define ZSTD_BLOCKHEADERSIZE 3 /* C standard doesn't allow `static const` variable to be init using another `static const` variable */
|
2020-09-23 12:58:38 -07:00
|
|
|
static UNUSED_ATTR const size_t ZSTD_blockHeaderSize = ZSTD_BLOCKHEADERSIZE;
|
2016-07-28 00:55:43 +02:00
|
|
|
typedef enum { bt_raw, bt_rle, bt_compressed, bt_reserved } blockType_e;
|
2016-03-19 15:11:42 +01:00
|
|
|
|
2020-01-03 16:53:51 -08:00
|
|
|
#define ZSTD_FRAMECHECKSUMSIZE 4
|
|
|
|
|
2016-03-19 15:11:42 +01:00
|
|
|
#define MIN_SEQUENCES_SIZE 1 /* nbSeq==0 */
|
2022-07-14 11:54:34 -07:00
|
|
|
#define MIN_CBLOCK_SIZE (1 /*litCSize*/ + 1 /* RLE or RAW */) /* for a non-null block */
|
2022-12-22 11:30:15 -08:00
|
|
|
#define MIN_LITERALS_FOR_4_STREAMS 6
|
2016-03-19 15:11:42 +01:00
|
|
|
|
2016-07-23 16:31:49 +02:00
|
|
|
typedef enum { set_basic, set_rle, set_compressed, set_repeat } symbolEncodingType_e;
|
2015-11-05 17:32:18 +01:00
|
|
|
|
2016-03-19 15:11:42 +01:00
|
|
|
#define LONGNBSEQ 0x7F00
|
|
|
|
|
2016-04-06 09:46:01 +02:00
|
|
|
#define MINMATCH 3
|
2015-11-11 21:38:21 +01:00
|
|
|
|
2016-02-03 18:47:30 +01:00
|
|
|
#define Litbits 8
|
2022-01-21 17:13:33 -08:00
|
|
|
#define LitHufLog 11
|
2016-02-03 22:56:55 +01:00
|
|
|
#define MaxLit ((1<<Litbits) - 1)
|
2018-02-09 04:25:15 -08:00
|
|
|
#define MaxML 52
|
|
|
|
#define MaxLL 35
|
2017-09-18 16:54:53 -07:00
|
|
|
#define DefaultMaxOff 28
|
2018-02-09 04:25:15 -08:00
|
|
|
#define MaxOff 31
|
2016-03-18 22:23:49 +01:00
|
|
|
#define MaxSeq MAX(MaxLL, MaxML) /* Assumption : MaxOff < MaxLL,MaxML */
|
2016-03-22 23:19:28 +01:00
|
|
|
#define MLFSELog 9
|
2016-03-21 00:07:42 +01:00
|
|
|
#define LLFSELog 9
|
2016-03-24 02:31:27 +01:00
|
|
|
#define OffFSELog 8
|
2018-02-09 04:25:15 -08:00
|
|
|
#define MaxFSELog MAX(MAX(MLFSELog, LLFSELog), OffFSELog)
|
2023-01-30 11:15:15 -08:00
|
|
|
#define MaxMLBits 16
|
|
|
|
#define MaxLLBits 16
|
2016-03-04 20:04:25 +01:00
|
|
|
|
2020-09-24 18:04:44 -07:00
|
|
|
#define ZSTD_MAX_HUF_HEADER_SIZE 128 /* header + <= 127 byte tree description */
|
|
|
|
/* Each table cannot take more than #symbols * FSELog bits */
|
|
|
|
#define ZSTD_MAX_FSE_HEADERS_SIZE (((MaxML + 1) * MLFSELog + (MaxLL + 1) * LLFSELog + (MaxOff + 1) * OffFSELog + 7) / 8)
|
|
|
|
|
2021-12-14 22:33:49 +01:00
|
|
|
static UNUSED_ATTR const U8 LL_bits[MaxLL+1] = {
|
2020-09-23 12:58:38 -07:00
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
1, 1, 1, 1, 2, 2, 3, 3,
|
|
|
|
4, 6, 7, 8, 9,10,11,12,
|
|
|
|
13,14,15,16
|
|
|
|
};
|
|
|
|
static UNUSED_ATTR const S16 LL_defaultNorm[MaxLL+1] = {
|
|
|
|
4, 3, 2, 2, 2, 2, 2, 2,
|
|
|
|
2, 2, 2, 2, 2, 1, 1, 1,
|
|
|
|
2, 2, 2, 2, 2, 2, 2, 2,
|
|
|
|
2, 3, 2, 1, 1, 1, 1, 1,
|
|
|
|
-1,-1,-1,-1
|
|
|
|
};
|
2016-09-22 15:57:28 +02:00
|
|
|
#define LL_DEFAULTNORMLOG 6 /* for static allocation */
|
2020-09-23 12:58:38 -07:00
|
|
|
static UNUSED_ATTR const U32 LL_defaultNormLog = LL_DEFAULTNORMLOG;
|
|
|
|
|
2021-12-14 22:33:49 +01:00
|
|
|
static UNUSED_ATTR const U8 ML_bits[MaxML+1] = {
|
2020-09-23 12:58:38 -07:00
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
1, 1, 1, 1, 2, 2, 3, 3,
|
|
|
|
4, 4, 5, 7, 8, 9,10,11,
|
|
|
|
12,13,14,15,16
|
|
|
|
};
|
|
|
|
static UNUSED_ATTR const S16 ML_defaultNorm[MaxML+1] = {
|
|
|
|
1, 4, 3, 2, 2, 2, 2, 2,
|
|
|
|
2, 1, 1, 1, 1, 1, 1, 1,
|
|
|
|
1, 1, 1, 1, 1, 1, 1, 1,
|
|
|
|
1, 1, 1, 1, 1, 1, 1, 1,
|
|
|
|
1, 1, 1, 1, 1, 1, 1, 1,
|
|
|
|
1, 1, 1, 1, 1, 1,-1,-1,
|
|
|
|
-1,-1,-1,-1,-1
|
|
|
|
};
|
2016-09-22 15:57:28 +02:00
|
|
|
#define ML_DEFAULTNORMLOG 6 /* for static allocation */
|
2020-09-23 12:58:38 -07:00
|
|
|
static UNUSED_ATTR const U32 ML_defaultNormLog = ML_DEFAULTNORMLOG;
|
|
|
|
|
|
|
|
static UNUSED_ATTR const S16 OF_defaultNorm[DefaultMaxOff+1] = {
|
|
|
|
1, 1, 1, 1, 1, 1, 2, 2,
|
|
|
|
2, 1, 1, 1, 1, 1, 1, 1,
|
|
|
|
1, 1, 1, 1, 1, 1, 1, 1,
|
|
|
|
-1,-1,-1,-1,-1
|
|
|
|
};
|
2016-09-22 15:57:28 +02:00
|
|
|
#define OF_DEFAULTNORMLOG 5 /* for static allocation */
|
2020-09-23 12:58:38 -07:00
|
|
|
static UNUSED_ATTR const U32 OF_defaultNormLog = OF_DEFAULTNORMLOG;
|
2016-04-07 15:24:29 +02:00
|
|
|
|
2015-10-29 16:49:43 +01:00
|
|
|
|
2016-01-28 00:18:06 +01:00
|
|
|
/*-*******************************************
|
2015-11-11 21:38:21 +01:00
|
|
|
* Shared functions to include for inlining
|
2016-01-28 00:18:06 +01:00
|
|
|
*********************************************/
|
2020-03-16 11:07:31 +08:00
|
|
|
static void ZSTD_copy8(void* dst, const void* src) {
|
2021-06-09 01:50:25 -04:00
|
|
|
#if defined(ZSTD_ARCH_ARM_NEON)
|
2020-03-16 11:07:31 +08:00
|
|
|
vst1_u8((uint8_t*)dst, vld1_u8((const uint8_t*)src));
|
|
|
|
#else
|
2020-08-10 12:46:38 -07:00
|
|
|
ZSTD_memcpy(dst, src, 8);
|
2020-03-16 11:07:31 +08:00
|
|
|
#endif
|
|
|
|
}
|
2023-11-21 13:26:25 -08:00
|
|
|
#define COPY8(d,s) do { ZSTD_copy8(d,s); d+=8; s+=8; } while (0)
|
2021-10-28 18:53:12 +08:00
|
|
|
|
|
|
|
/* Need to use memmove here since the literal buffer can now be located within
|
|
|
|
the dst buffer. In circumstances where the op "catches up" to where the
|
|
|
|
literal buffer is, there can be partial overlaps in this call on the final
|
|
|
|
copy if the literal is being shifted by less than 16 bytes. */
|
2020-03-16 11:07:31 +08:00
|
|
|
static void ZSTD_copy16(void* dst, const void* src) {
|
2021-06-09 01:50:25 -04:00
|
|
|
#if defined(ZSTD_ARCH_ARM_NEON)
|
2020-03-16 11:07:31 +08:00
|
|
|
vst1q_u8((uint8_t*)dst, vld1q_u8((const uint8_t*)src));
|
2021-10-28 18:53:12 +08:00
|
|
|
#elif defined(ZSTD_ARCH_X86_SSE2)
|
|
|
|
_mm_storeu_si128((__m128i*)dst, _mm_loadu_si128((const __m128i*)src));
|
2021-12-14 15:53:50 -05:00
|
|
|
#elif defined(__clang__)
|
2021-10-25 10:38:01 -04:00
|
|
|
ZSTD_memmove(dst, src, 16);
|
2021-12-14 15:53:50 -05:00
|
|
|
#else
|
|
|
|
/* ZSTD_memmove is not inlined properly by gcc */
|
|
|
|
BYTE copy16_buf[16];
|
|
|
|
ZSTD_memcpy(copy16_buf, src, 16);
|
|
|
|
ZSTD_memcpy(dst, copy16_buf, 16);
|
2020-03-16 11:07:31 +08:00
|
|
|
#endif
|
|
|
|
}
|
2023-11-21 13:26:25 -08:00
|
|
|
#define COPY16(d,s) do { ZSTD_copy16(d,s); d+=16; s+=16; } while (0)
|
perf improvements for zstd decode (#1668)
* perf improvements for zstd decode
tldr: 7.5% average decode speedup on silesia corpus at compression levels 1-3 (sandy bridge)
Background: while investigating zstd perf differences between clang and gcc I noticed that even though gcc is vectorizing the loop in in wildcopy, it was not being done as well as could be done by hand. The sites where wildcopy is invoked have an interesting distribution of lengths to be copied. The loop trip count is rarely above 1, yet long copies are common enough to make their performance important.The code in zstd_decompress.c to invoke wildcopy handles the latter well but the gcc autovectorizer introduces a needlessly expensive startup check for vectorization.
See how GCC autovectorizes the loop here:
https://godbolt.org/z/apr0x0
Here is the code after this diff has been applied: (left hand side is the good one, right is with vectorizer on)
After: https://godbolt.org/z/OwO4F8
Note that autovectorization still does not do a good job on the optimized version, so it's turned off\
via attribute and flag. I found that neither attribute nor command-line flag were entirely successful in turning off vectorization, which is why there were both.
silesia benchmark data - second triad of each file is with the original code:
file orig compressedratio encode decode change
1#dickens 10192446-> 4268865(2.388), 198.9MB/s 709.6MB/s
2#dickens 10192446-> 3876126(2.630), 128.7MB/s 552.5MB/s
3#dickens 10192446-> 3682956(2.767), 104.6MB/s 537MB/s
1#dickens 10192446-> 4268865(2.388), 195.4MB/s 659.5MB/s 7.60%
2#dickens 10192446-> 3876126(2.630), 127MB/s 516.3MB/s 7.01%
3#dickens 10192446-> 3682956(2.767), 105MB/s 479.5MB/s 11.99%
1#mozilla 51220480-> 20117517(2.546), 285.4MB/s 734.9MB/s
2#mozilla 51220480-> 19067018(2.686), 220.8MB/s 686.3MB/s
3#mozilla 51220480-> 18508283(2.767), 152.2MB/s 669.4MB/s
1#mozilla 51220480-> 20117517(2.546), 283.4MB/s 697.9MB/s 5.30%
2#mozilla 51220480-> 19067018(2.686), 225.9MB/s 665MB/s 3.20%
3#mozilla 51220480-> 18508283(2.767), 154.5MB/s 640.6MB/s 4.50%
1#mr 9970564-> 3840242(2.596), 262.4MB/s 899.8MB/s
2#mr 9970564-> 3600976(2.769), 181.2MB/s 717.9MB/s
3#mr 9970564-> 3563987(2.798), 116.3MB/s 620MB/s
1#mr 9970564-> 3840242(2.596), 253.2MB/s 827.3MB/s 8.76%
2#mr 9970564-> 3600976(2.769), 177.4MB/s 655.4MB/s 9.54%
3#mr 9970564-> 3563987(2.798), 111.2MB/s 564.2MB/s 9.89%
1#nci 33553445-> 2849306(11.78), 575.2MB/s , 1335.8MB/s
2#nci 33553445-> 2890166(11.61), 509.3MB/s , 1238.1MB/s
3#nci 33553445-> 2857408(11.74), 431MB/s , 1210.7MB/s
1#nci 33553445-> 2849306(11.78), 565.4MB/s , 1220.2MB/s 9.47%
2#nci 33553445-> 2890166(11.61), 508.2MB/s , 1128.4MB/s 9.72%
3#nci 33553445-> 2857408(11.74), 429.1MB/s , 1097.7MB/s 10.29%
1#ooffice 6152192-> 3590954(1.713), 231.4MB/s , 662.6MB/s
2#ooffice 6152192-> 3323931(1.851), 162.8MB/s , 592.6MB/s
3#ooffice 6152192-> 3145625(1.956), 99.9MB/s , 549.6MB/s
1#ooffice 6152192-> 3590954(1.713), 224.7MB/s , 624.2MB/s 6.15%
2#ooffice 6152192-> 3323931 (1.851), 155MB/s , 564.5MB/s 4.98%
3#ooffice 6152192-> 3145625(1.956), 101.1MB/s , 521.2MB/s 5.45%
1#osdb 10085684-> 3739042(2.697), 271.9MB/s 876.4MB/s
2#osdb 10085684-> 3493875(2.887), 208.2MB/s 857MB/s
3#osdb 10085684-> 3515831(2.869), 135.3MB/s 805.4MB/s
1#osdb 10085684-> 3739042(2.697), 257.4MB/s 793.8MB/s 10.41%
2#osdb 10085684-> 3493875(2.887), 209.7MB/s 776.1MB/s 10.42%
3#osdb 10085684-> 3515831(2.869), 130.6MB/s 727.7MB/s 10.68%
1#reymont 6627202-> 2152771(3.078), 198.9MB/s 696.2MB/s
2#reymont 6627202-> 2071140(3.200), 170MB/s 595.2MB/s
3#reymont 6627202-> 1953597(3.392), 128.5MB/s 609.7MB/s
1#reymont 6627202-> 2152771(3.078), 199.6MB/s 655.2MB/s 6.26%
2#reymont 6627202-> 2071140(3.200), 168.2MB/s 554.4MB/s 7.36%
3#reymont 6627202-> 1953597(3.392), 128.7MB/s 557.4MB/s 9.38%
1#samba 21606400-> 5510994(3.921), 338.1MB/s 1066MB/s
2#samba 21606400-> 5240208(4.123), 258.7MB/s 992.3MB/s
3#samba 21606400-> 5003358(4.318), 200.2MB/s 991.1MB/s
1#samba 21606400-> 5510994(3.921), 330.8MB/s 974MB/s 9.45%
2#samba 21606400-> 5240208(4.123), 257.9MB/s 919.4MB/s 7.93%
3#samba 21606400-> 5003358(4.318), 198.5MB/s 908.9MB/s 9.04%
1#sao 7251944-> 6256401(1.159), 194.6MB/s 602.2MB/s
2#sao 7251944-> 5808761(1.248), 128.2MB/s 532.1MB/s
3#sao 7251944-> 5556318(1.305), 73MB/s 509.4MB/s
1#sao 7251944-> 6256401(1.159), 198.7MB/s 580.7MB/s 3.70%
2#sao 7251944-> 5808761(1.248), 129.1MB/s 502.7MB/s 5.85%
3#sao 7251944-> 5556318(1.305), 74.6MB/s 493.1MB/s 3.31%
1#webster 41458703-> 13692222(3.028), 222.3MB/s 752MB/s
2#webster 41458703-> 12842646(3.228), 157.6MB/s 532.2MB/s
3#webster 41458703-> 12191964(3.400), 124MB/s 468.5MB/s
1#webster 41458703-> 13692222(3.028), 219.7MB/s 697MB/s 7.89%
2#webster 41458703-> 12842646(3.228), 153.9MB/s 495.4MB/s 7.43%
3#webster 41458703-> 12191964(3.400), 124.8MB/s 444.8MB/s 5.33%
1#xml 5345280-> 696652(7.673), 485MB/s , 1333.9MB/s
2#xml 5345280-> 681492(7.843), 405.2MB/s , 1237.5MB/s
3#xml 5345280-> 639057(8.364), 328.5MB/s , 1281.3MB/s
1#xml 5345280-> 696652(7.673), 473.1MB/s , 1232.4MB/s 8.24%
2#xml 5345280-> 681492(7.843), 398.6MB/s , 1145.9MB/s 7.99%
3#xml 5345280-> 639057(8.364), 327.1MB/s , 1175MB/s 9.05%
1#x-ray 8474240-> 6772557(1.251), 521.3MB/s 762.6MB/s
2#x-ray 8474240-> 6684531(1.268), 230.5MB/s 688.5MB/s
3#x-ray 8474240-> 6166679(1.374), 68.7MB/s 478.8MB/s
1#x-ray 8474240-> 6772557(1.251), 502.8MB/s 736.7MB/s 3.52%
2#x-ray 8474240-> 6684531(1.268), 224.4MB/s 662MB/s 4.00%
3#x-ray 8474240-> 6166679(1.374), 67.3MB/s 437.8MB/s 9.37%
7.51%
* makefile changed to only pass -fno-tree-vectorize to gcc
* <Replace this line with a title. Use 1 line only, 67 chars or less>
Don't add "no-tree-vectorize" attribute on clang (which defines __GNUC__)
* fix for warning/error with subtraction of void* pointers
* fix c90 conformance issue - ISO C90 forbids mixed declarations and code
* Fix assert for negative diff, only when there is no overlap
* fix overflow revealed in fuzzing tests
* tweak for small speed increase
2019-07-11 15:31:07 -07:00
|
|
|
|
2019-09-20 00:52:15 -07:00
|
|
|
#define WILDCOPY_OVERLENGTH 32
|
2019-09-19 13:25:03 -07:00
|
|
|
#define WILDCOPY_VECLEN 16
|
perf improvements for zstd decode (#1668)
* perf improvements for zstd decode
tldr: 7.5% average decode speedup on silesia corpus at compression levels 1-3 (sandy bridge)
Background: while investigating zstd perf differences between clang and gcc I noticed that even though gcc is vectorizing the loop in in wildcopy, it was not being done as well as could be done by hand. The sites where wildcopy is invoked have an interesting distribution of lengths to be copied. The loop trip count is rarely above 1, yet long copies are common enough to make their performance important.The code in zstd_decompress.c to invoke wildcopy handles the latter well but the gcc autovectorizer introduces a needlessly expensive startup check for vectorization.
See how GCC autovectorizes the loop here:
https://godbolt.org/z/apr0x0
Here is the code after this diff has been applied: (left hand side is the good one, right is with vectorizer on)
After: https://godbolt.org/z/OwO4F8
Note that autovectorization still does not do a good job on the optimized version, so it's turned off\
via attribute and flag. I found that neither attribute nor command-line flag were entirely successful in turning off vectorization, which is why there were both.
silesia benchmark data - second triad of each file is with the original code:
file orig compressedratio encode decode change
1#dickens 10192446-> 4268865(2.388), 198.9MB/s 709.6MB/s
2#dickens 10192446-> 3876126(2.630), 128.7MB/s 552.5MB/s
3#dickens 10192446-> 3682956(2.767), 104.6MB/s 537MB/s
1#dickens 10192446-> 4268865(2.388), 195.4MB/s 659.5MB/s 7.60%
2#dickens 10192446-> 3876126(2.630), 127MB/s 516.3MB/s 7.01%
3#dickens 10192446-> 3682956(2.767), 105MB/s 479.5MB/s 11.99%
1#mozilla 51220480-> 20117517(2.546), 285.4MB/s 734.9MB/s
2#mozilla 51220480-> 19067018(2.686), 220.8MB/s 686.3MB/s
3#mozilla 51220480-> 18508283(2.767), 152.2MB/s 669.4MB/s
1#mozilla 51220480-> 20117517(2.546), 283.4MB/s 697.9MB/s 5.30%
2#mozilla 51220480-> 19067018(2.686), 225.9MB/s 665MB/s 3.20%
3#mozilla 51220480-> 18508283(2.767), 154.5MB/s 640.6MB/s 4.50%
1#mr 9970564-> 3840242(2.596), 262.4MB/s 899.8MB/s
2#mr 9970564-> 3600976(2.769), 181.2MB/s 717.9MB/s
3#mr 9970564-> 3563987(2.798), 116.3MB/s 620MB/s
1#mr 9970564-> 3840242(2.596), 253.2MB/s 827.3MB/s 8.76%
2#mr 9970564-> 3600976(2.769), 177.4MB/s 655.4MB/s 9.54%
3#mr 9970564-> 3563987(2.798), 111.2MB/s 564.2MB/s 9.89%
1#nci 33553445-> 2849306(11.78), 575.2MB/s , 1335.8MB/s
2#nci 33553445-> 2890166(11.61), 509.3MB/s , 1238.1MB/s
3#nci 33553445-> 2857408(11.74), 431MB/s , 1210.7MB/s
1#nci 33553445-> 2849306(11.78), 565.4MB/s , 1220.2MB/s 9.47%
2#nci 33553445-> 2890166(11.61), 508.2MB/s , 1128.4MB/s 9.72%
3#nci 33553445-> 2857408(11.74), 429.1MB/s , 1097.7MB/s 10.29%
1#ooffice 6152192-> 3590954(1.713), 231.4MB/s , 662.6MB/s
2#ooffice 6152192-> 3323931(1.851), 162.8MB/s , 592.6MB/s
3#ooffice 6152192-> 3145625(1.956), 99.9MB/s , 549.6MB/s
1#ooffice 6152192-> 3590954(1.713), 224.7MB/s , 624.2MB/s 6.15%
2#ooffice 6152192-> 3323931 (1.851), 155MB/s , 564.5MB/s 4.98%
3#ooffice 6152192-> 3145625(1.956), 101.1MB/s , 521.2MB/s 5.45%
1#osdb 10085684-> 3739042(2.697), 271.9MB/s 876.4MB/s
2#osdb 10085684-> 3493875(2.887), 208.2MB/s 857MB/s
3#osdb 10085684-> 3515831(2.869), 135.3MB/s 805.4MB/s
1#osdb 10085684-> 3739042(2.697), 257.4MB/s 793.8MB/s 10.41%
2#osdb 10085684-> 3493875(2.887), 209.7MB/s 776.1MB/s 10.42%
3#osdb 10085684-> 3515831(2.869), 130.6MB/s 727.7MB/s 10.68%
1#reymont 6627202-> 2152771(3.078), 198.9MB/s 696.2MB/s
2#reymont 6627202-> 2071140(3.200), 170MB/s 595.2MB/s
3#reymont 6627202-> 1953597(3.392), 128.5MB/s 609.7MB/s
1#reymont 6627202-> 2152771(3.078), 199.6MB/s 655.2MB/s 6.26%
2#reymont 6627202-> 2071140(3.200), 168.2MB/s 554.4MB/s 7.36%
3#reymont 6627202-> 1953597(3.392), 128.7MB/s 557.4MB/s 9.38%
1#samba 21606400-> 5510994(3.921), 338.1MB/s 1066MB/s
2#samba 21606400-> 5240208(4.123), 258.7MB/s 992.3MB/s
3#samba 21606400-> 5003358(4.318), 200.2MB/s 991.1MB/s
1#samba 21606400-> 5510994(3.921), 330.8MB/s 974MB/s 9.45%
2#samba 21606400-> 5240208(4.123), 257.9MB/s 919.4MB/s 7.93%
3#samba 21606400-> 5003358(4.318), 198.5MB/s 908.9MB/s 9.04%
1#sao 7251944-> 6256401(1.159), 194.6MB/s 602.2MB/s
2#sao 7251944-> 5808761(1.248), 128.2MB/s 532.1MB/s
3#sao 7251944-> 5556318(1.305), 73MB/s 509.4MB/s
1#sao 7251944-> 6256401(1.159), 198.7MB/s 580.7MB/s 3.70%
2#sao 7251944-> 5808761(1.248), 129.1MB/s 502.7MB/s 5.85%
3#sao 7251944-> 5556318(1.305), 74.6MB/s 493.1MB/s 3.31%
1#webster 41458703-> 13692222(3.028), 222.3MB/s 752MB/s
2#webster 41458703-> 12842646(3.228), 157.6MB/s 532.2MB/s
3#webster 41458703-> 12191964(3.400), 124MB/s 468.5MB/s
1#webster 41458703-> 13692222(3.028), 219.7MB/s 697MB/s 7.89%
2#webster 41458703-> 12842646(3.228), 153.9MB/s 495.4MB/s 7.43%
3#webster 41458703-> 12191964(3.400), 124.8MB/s 444.8MB/s 5.33%
1#xml 5345280-> 696652(7.673), 485MB/s , 1333.9MB/s
2#xml 5345280-> 681492(7.843), 405.2MB/s , 1237.5MB/s
3#xml 5345280-> 639057(8.364), 328.5MB/s , 1281.3MB/s
1#xml 5345280-> 696652(7.673), 473.1MB/s , 1232.4MB/s 8.24%
2#xml 5345280-> 681492(7.843), 398.6MB/s , 1145.9MB/s 7.99%
3#xml 5345280-> 639057(8.364), 327.1MB/s , 1175MB/s 9.05%
1#x-ray 8474240-> 6772557(1.251), 521.3MB/s 762.6MB/s
2#x-ray 8474240-> 6684531(1.268), 230.5MB/s 688.5MB/s
3#x-ray 8474240-> 6166679(1.374), 68.7MB/s 478.8MB/s
1#x-ray 8474240-> 6772557(1.251), 502.8MB/s 736.7MB/s 3.52%
2#x-ray 8474240-> 6684531(1.268), 224.4MB/s 662MB/s 4.00%
3#x-ray 8474240-> 6166679(1.374), 67.3MB/s 437.8MB/s 9.37%
7.51%
* makefile changed to only pass -fno-tree-vectorize to gcc
* <Replace this line with a title. Use 1 line only, 67 chars or less>
Don't add "no-tree-vectorize" attribute on clang (which defines __GNUC__)
* fix for warning/error with subtraction of void* pointers
* fix c90 conformance issue - ISO C90 forbids mixed declarations and code
* Fix assert for negative diff, only when there is no overlap
* fix overflow revealed in fuzzing tests
* tweak for small speed increase
2019-07-11 15:31:07 -07:00
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
ZSTD_no_overlap,
|
2019-09-24 17:50:58 -07:00
|
|
|
ZSTD_overlap_src_before_dst
|
perf improvements for zstd decode (#1668)
* perf improvements for zstd decode
tldr: 7.5% average decode speedup on silesia corpus at compression levels 1-3 (sandy bridge)
Background: while investigating zstd perf differences between clang and gcc I noticed that even though gcc is vectorizing the loop in in wildcopy, it was not being done as well as could be done by hand. The sites where wildcopy is invoked have an interesting distribution of lengths to be copied. The loop trip count is rarely above 1, yet long copies are common enough to make their performance important.The code in zstd_decompress.c to invoke wildcopy handles the latter well but the gcc autovectorizer introduces a needlessly expensive startup check for vectorization.
See how GCC autovectorizes the loop here:
https://godbolt.org/z/apr0x0
Here is the code after this diff has been applied: (left hand side is the good one, right is with vectorizer on)
After: https://godbolt.org/z/OwO4F8
Note that autovectorization still does not do a good job on the optimized version, so it's turned off\
via attribute and flag. I found that neither attribute nor command-line flag were entirely successful in turning off vectorization, which is why there were both.
silesia benchmark data - second triad of each file is with the original code:
file orig compressedratio encode decode change
1#dickens 10192446-> 4268865(2.388), 198.9MB/s 709.6MB/s
2#dickens 10192446-> 3876126(2.630), 128.7MB/s 552.5MB/s
3#dickens 10192446-> 3682956(2.767), 104.6MB/s 537MB/s
1#dickens 10192446-> 4268865(2.388), 195.4MB/s 659.5MB/s 7.60%
2#dickens 10192446-> 3876126(2.630), 127MB/s 516.3MB/s 7.01%
3#dickens 10192446-> 3682956(2.767), 105MB/s 479.5MB/s 11.99%
1#mozilla 51220480-> 20117517(2.546), 285.4MB/s 734.9MB/s
2#mozilla 51220480-> 19067018(2.686), 220.8MB/s 686.3MB/s
3#mozilla 51220480-> 18508283(2.767), 152.2MB/s 669.4MB/s
1#mozilla 51220480-> 20117517(2.546), 283.4MB/s 697.9MB/s 5.30%
2#mozilla 51220480-> 19067018(2.686), 225.9MB/s 665MB/s 3.20%
3#mozilla 51220480-> 18508283(2.767), 154.5MB/s 640.6MB/s 4.50%
1#mr 9970564-> 3840242(2.596), 262.4MB/s 899.8MB/s
2#mr 9970564-> 3600976(2.769), 181.2MB/s 717.9MB/s
3#mr 9970564-> 3563987(2.798), 116.3MB/s 620MB/s
1#mr 9970564-> 3840242(2.596), 253.2MB/s 827.3MB/s 8.76%
2#mr 9970564-> 3600976(2.769), 177.4MB/s 655.4MB/s 9.54%
3#mr 9970564-> 3563987(2.798), 111.2MB/s 564.2MB/s 9.89%
1#nci 33553445-> 2849306(11.78), 575.2MB/s , 1335.8MB/s
2#nci 33553445-> 2890166(11.61), 509.3MB/s , 1238.1MB/s
3#nci 33553445-> 2857408(11.74), 431MB/s , 1210.7MB/s
1#nci 33553445-> 2849306(11.78), 565.4MB/s , 1220.2MB/s 9.47%
2#nci 33553445-> 2890166(11.61), 508.2MB/s , 1128.4MB/s 9.72%
3#nci 33553445-> 2857408(11.74), 429.1MB/s , 1097.7MB/s 10.29%
1#ooffice 6152192-> 3590954(1.713), 231.4MB/s , 662.6MB/s
2#ooffice 6152192-> 3323931(1.851), 162.8MB/s , 592.6MB/s
3#ooffice 6152192-> 3145625(1.956), 99.9MB/s , 549.6MB/s
1#ooffice 6152192-> 3590954(1.713), 224.7MB/s , 624.2MB/s 6.15%
2#ooffice 6152192-> 3323931 (1.851), 155MB/s , 564.5MB/s 4.98%
3#ooffice 6152192-> 3145625(1.956), 101.1MB/s , 521.2MB/s 5.45%
1#osdb 10085684-> 3739042(2.697), 271.9MB/s 876.4MB/s
2#osdb 10085684-> 3493875(2.887), 208.2MB/s 857MB/s
3#osdb 10085684-> 3515831(2.869), 135.3MB/s 805.4MB/s
1#osdb 10085684-> 3739042(2.697), 257.4MB/s 793.8MB/s 10.41%
2#osdb 10085684-> 3493875(2.887), 209.7MB/s 776.1MB/s 10.42%
3#osdb 10085684-> 3515831(2.869), 130.6MB/s 727.7MB/s 10.68%
1#reymont 6627202-> 2152771(3.078), 198.9MB/s 696.2MB/s
2#reymont 6627202-> 2071140(3.200), 170MB/s 595.2MB/s
3#reymont 6627202-> 1953597(3.392), 128.5MB/s 609.7MB/s
1#reymont 6627202-> 2152771(3.078), 199.6MB/s 655.2MB/s 6.26%
2#reymont 6627202-> 2071140(3.200), 168.2MB/s 554.4MB/s 7.36%
3#reymont 6627202-> 1953597(3.392), 128.7MB/s 557.4MB/s 9.38%
1#samba 21606400-> 5510994(3.921), 338.1MB/s 1066MB/s
2#samba 21606400-> 5240208(4.123), 258.7MB/s 992.3MB/s
3#samba 21606400-> 5003358(4.318), 200.2MB/s 991.1MB/s
1#samba 21606400-> 5510994(3.921), 330.8MB/s 974MB/s 9.45%
2#samba 21606400-> 5240208(4.123), 257.9MB/s 919.4MB/s 7.93%
3#samba 21606400-> 5003358(4.318), 198.5MB/s 908.9MB/s 9.04%
1#sao 7251944-> 6256401(1.159), 194.6MB/s 602.2MB/s
2#sao 7251944-> 5808761(1.248), 128.2MB/s 532.1MB/s
3#sao 7251944-> 5556318(1.305), 73MB/s 509.4MB/s
1#sao 7251944-> 6256401(1.159), 198.7MB/s 580.7MB/s 3.70%
2#sao 7251944-> 5808761(1.248), 129.1MB/s 502.7MB/s 5.85%
3#sao 7251944-> 5556318(1.305), 74.6MB/s 493.1MB/s 3.31%
1#webster 41458703-> 13692222(3.028), 222.3MB/s 752MB/s
2#webster 41458703-> 12842646(3.228), 157.6MB/s 532.2MB/s
3#webster 41458703-> 12191964(3.400), 124MB/s 468.5MB/s
1#webster 41458703-> 13692222(3.028), 219.7MB/s 697MB/s 7.89%
2#webster 41458703-> 12842646(3.228), 153.9MB/s 495.4MB/s 7.43%
3#webster 41458703-> 12191964(3.400), 124.8MB/s 444.8MB/s 5.33%
1#xml 5345280-> 696652(7.673), 485MB/s , 1333.9MB/s
2#xml 5345280-> 681492(7.843), 405.2MB/s , 1237.5MB/s
3#xml 5345280-> 639057(8.364), 328.5MB/s , 1281.3MB/s
1#xml 5345280-> 696652(7.673), 473.1MB/s , 1232.4MB/s 8.24%
2#xml 5345280-> 681492(7.843), 398.6MB/s , 1145.9MB/s 7.99%
3#xml 5345280-> 639057(8.364), 327.1MB/s , 1175MB/s 9.05%
1#x-ray 8474240-> 6772557(1.251), 521.3MB/s 762.6MB/s
2#x-ray 8474240-> 6684531(1.268), 230.5MB/s 688.5MB/s
3#x-ray 8474240-> 6166679(1.374), 68.7MB/s 478.8MB/s
1#x-ray 8474240-> 6772557(1.251), 502.8MB/s 736.7MB/s 3.52%
2#x-ray 8474240-> 6684531(1.268), 224.4MB/s 662MB/s 4.00%
3#x-ray 8474240-> 6166679(1.374), 67.3MB/s 437.8MB/s 9.37%
7.51%
* makefile changed to only pass -fno-tree-vectorize to gcc
* <Replace this line with a title. Use 1 line only, 67 chars or less>
Don't add "no-tree-vectorize" attribute on clang (which defines __GNUC__)
* fix for warning/error with subtraction of void* pointers
* fix c90 conformance issue - ISO C90 forbids mixed declarations and code
* Fix assert for negative diff, only when there is no overlap
* fix overflow revealed in fuzzing tests
* tweak for small speed increase
2019-07-11 15:31:07 -07:00
|
|
|
/* ZSTD_overlap_dst_before_src, */
|
|
|
|
} ZSTD_overlap_e;
|
2015-10-29 16:49:43 +01:00
|
|
|
|
2016-02-04 15:28:14 +01:00
|
|
|
/*! ZSTD_wildcopy() :
|
2020-08-10 12:46:38 -07:00
|
|
|
* Custom version of ZSTD_memcpy(), can over read/write up to WILDCOPY_OVERLENGTH bytes (if length==0)
|
2019-09-19 13:25:03 -07:00
|
|
|
* @param ovtype controls the overlap detection
|
|
|
|
* - ZSTD_no_overlap: The source and destination are guaranteed to be at least WILDCOPY_VECLEN bytes apart.
|
|
|
|
* - ZSTD_overlap_src_before_dst: The src and dst may overlap, but they MUST be at least 8 bytes apart.
|
|
|
|
* The src buffer must be before the dst buffer.
|
|
|
|
*/
|
2020-07-24 10:53:58 -07:00
|
|
|
MEM_STATIC FORCE_INLINE_ATTR
|
2019-09-20 12:23:25 -07:00
|
|
|
void ZSTD_wildcopy(void* dst, const void* src, ptrdiff_t length, ZSTD_overlap_e const ovtype)
|
perf improvements for zstd decode (#1668)
* perf improvements for zstd decode
tldr: 7.5% average decode speedup on silesia corpus at compression levels 1-3 (sandy bridge)
Background: while investigating zstd perf differences between clang and gcc I noticed that even though gcc is vectorizing the loop in in wildcopy, it was not being done as well as could be done by hand. The sites where wildcopy is invoked have an interesting distribution of lengths to be copied. The loop trip count is rarely above 1, yet long copies are common enough to make their performance important.The code in zstd_decompress.c to invoke wildcopy handles the latter well but the gcc autovectorizer introduces a needlessly expensive startup check for vectorization.
See how GCC autovectorizes the loop here:
https://godbolt.org/z/apr0x0
Here is the code after this diff has been applied: (left hand side is the good one, right is with vectorizer on)
After: https://godbolt.org/z/OwO4F8
Note that autovectorization still does not do a good job on the optimized version, so it's turned off\
via attribute and flag. I found that neither attribute nor command-line flag were entirely successful in turning off vectorization, which is why there were both.
silesia benchmark data - second triad of each file is with the original code:
file orig compressedratio encode decode change
1#dickens 10192446-> 4268865(2.388), 198.9MB/s 709.6MB/s
2#dickens 10192446-> 3876126(2.630), 128.7MB/s 552.5MB/s
3#dickens 10192446-> 3682956(2.767), 104.6MB/s 537MB/s
1#dickens 10192446-> 4268865(2.388), 195.4MB/s 659.5MB/s 7.60%
2#dickens 10192446-> 3876126(2.630), 127MB/s 516.3MB/s 7.01%
3#dickens 10192446-> 3682956(2.767), 105MB/s 479.5MB/s 11.99%
1#mozilla 51220480-> 20117517(2.546), 285.4MB/s 734.9MB/s
2#mozilla 51220480-> 19067018(2.686), 220.8MB/s 686.3MB/s
3#mozilla 51220480-> 18508283(2.767), 152.2MB/s 669.4MB/s
1#mozilla 51220480-> 20117517(2.546), 283.4MB/s 697.9MB/s 5.30%
2#mozilla 51220480-> 19067018(2.686), 225.9MB/s 665MB/s 3.20%
3#mozilla 51220480-> 18508283(2.767), 154.5MB/s 640.6MB/s 4.50%
1#mr 9970564-> 3840242(2.596), 262.4MB/s 899.8MB/s
2#mr 9970564-> 3600976(2.769), 181.2MB/s 717.9MB/s
3#mr 9970564-> 3563987(2.798), 116.3MB/s 620MB/s
1#mr 9970564-> 3840242(2.596), 253.2MB/s 827.3MB/s 8.76%
2#mr 9970564-> 3600976(2.769), 177.4MB/s 655.4MB/s 9.54%
3#mr 9970564-> 3563987(2.798), 111.2MB/s 564.2MB/s 9.89%
1#nci 33553445-> 2849306(11.78), 575.2MB/s , 1335.8MB/s
2#nci 33553445-> 2890166(11.61), 509.3MB/s , 1238.1MB/s
3#nci 33553445-> 2857408(11.74), 431MB/s , 1210.7MB/s
1#nci 33553445-> 2849306(11.78), 565.4MB/s , 1220.2MB/s 9.47%
2#nci 33553445-> 2890166(11.61), 508.2MB/s , 1128.4MB/s 9.72%
3#nci 33553445-> 2857408(11.74), 429.1MB/s , 1097.7MB/s 10.29%
1#ooffice 6152192-> 3590954(1.713), 231.4MB/s , 662.6MB/s
2#ooffice 6152192-> 3323931(1.851), 162.8MB/s , 592.6MB/s
3#ooffice 6152192-> 3145625(1.956), 99.9MB/s , 549.6MB/s
1#ooffice 6152192-> 3590954(1.713), 224.7MB/s , 624.2MB/s 6.15%
2#ooffice 6152192-> 3323931 (1.851), 155MB/s , 564.5MB/s 4.98%
3#ooffice 6152192-> 3145625(1.956), 101.1MB/s , 521.2MB/s 5.45%
1#osdb 10085684-> 3739042(2.697), 271.9MB/s 876.4MB/s
2#osdb 10085684-> 3493875(2.887), 208.2MB/s 857MB/s
3#osdb 10085684-> 3515831(2.869), 135.3MB/s 805.4MB/s
1#osdb 10085684-> 3739042(2.697), 257.4MB/s 793.8MB/s 10.41%
2#osdb 10085684-> 3493875(2.887), 209.7MB/s 776.1MB/s 10.42%
3#osdb 10085684-> 3515831(2.869), 130.6MB/s 727.7MB/s 10.68%
1#reymont 6627202-> 2152771(3.078), 198.9MB/s 696.2MB/s
2#reymont 6627202-> 2071140(3.200), 170MB/s 595.2MB/s
3#reymont 6627202-> 1953597(3.392), 128.5MB/s 609.7MB/s
1#reymont 6627202-> 2152771(3.078), 199.6MB/s 655.2MB/s 6.26%
2#reymont 6627202-> 2071140(3.200), 168.2MB/s 554.4MB/s 7.36%
3#reymont 6627202-> 1953597(3.392), 128.7MB/s 557.4MB/s 9.38%
1#samba 21606400-> 5510994(3.921), 338.1MB/s 1066MB/s
2#samba 21606400-> 5240208(4.123), 258.7MB/s 992.3MB/s
3#samba 21606400-> 5003358(4.318), 200.2MB/s 991.1MB/s
1#samba 21606400-> 5510994(3.921), 330.8MB/s 974MB/s 9.45%
2#samba 21606400-> 5240208(4.123), 257.9MB/s 919.4MB/s 7.93%
3#samba 21606400-> 5003358(4.318), 198.5MB/s 908.9MB/s 9.04%
1#sao 7251944-> 6256401(1.159), 194.6MB/s 602.2MB/s
2#sao 7251944-> 5808761(1.248), 128.2MB/s 532.1MB/s
3#sao 7251944-> 5556318(1.305), 73MB/s 509.4MB/s
1#sao 7251944-> 6256401(1.159), 198.7MB/s 580.7MB/s 3.70%
2#sao 7251944-> 5808761(1.248), 129.1MB/s 502.7MB/s 5.85%
3#sao 7251944-> 5556318(1.305), 74.6MB/s 493.1MB/s 3.31%
1#webster 41458703-> 13692222(3.028), 222.3MB/s 752MB/s
2#webster 41458703-> 12842646(3.228), 157.6MB/s 532.2MB/s
3#webster 41458703-> 12191964(3.400), 124MB/s 468.5MB/s
1#webster 41458703-> 13692222(3.028), 219.7MB/s 697MB/s 7.89%
2#webster 41458703-> 12842646(3.228), 153.9MB/s 495.4MB/s 7.43%
3#webster 41458703-> 12191964(3.400), 124.8MB/s 444.8MB/s 5.33%
1#xml 5345280-> 696652(7.673), 485MB/s , 1333.9MB/s
2#xml 5345280-> 681492(7.843), 405.2MB/s , 1237.5MB/s
3#xml 5345280-> 639057(8.364), 328.5MB/s , 1281.3MB/s
1#xml 5345280-> 696652(7.673), 473.1MB/s , 1232.4MB/s 8.24%
2#xml 5345280-> 681492(7.843), 398.6MB/s , 1145.9MB/s 7.99%
3#xml 5345280-> 639057(8.364), 327.1MB/s , 1175MB/s 9.05%
1#x-ray 8474240-> 6772557(1.251), 521.3MB/s 762.6MB/s
2#x-ray 8474240-> 6684531(1.268), 230.5MB/s 688.5MB/s
3#x-ray 8474240-> 6166679(1.374), 68.7MB/s 478.8MB/s
1#x-ray 8474240-> 6772557(1.251), 502.8MB/s 736.7MB/s 3.52%
2#x-ray 8474240-> 6684531(1.268), 224.4MB/s 662MB/s 4.00%
3#x-ray 8474240-> 6166679(1.374), 67.3MB/s 437.8MB/s 9.37%
7.51%
* makefile changed to only pass -fno-tree-vectorize to gcc
* <Replace this line with a title. Use 1 line only, 67 chars or less>
Don't add "no-tree-vectorize" attribute on clang (which defines __GNUC__)
* fix for warning/error with subtraction of void* pointers
* fix c90 conformance issue - ISO C90 forbids mixed declarations and code
* Fix assert for negative diff, only when there is no overlap
* fix overflow revealed in fuzzing tests
* tweak for small speed increase
2019-07-11 15:31:07 -07:00
|
|
|
{
|
|
|
|
ptrdiff_t diff = (BYTE*)dst - (const BYTE*)src;
|
|
|
|
const BYTE* ip = (const BYTE*)src;
|
|
|
|
BYTE* op = (BYTE*)dst;
|
|
|
|
BYTE* const oend = op + length;
|
|
|
|
|
2019-09-19 13:25:03 -07:00
|
|
|
if (ovtype == ZSTD_overlap_src_before_dst && diff < WILDCOPY_VECLEN) {
|
|
|
|
/* Handle short offset copies. */
|
2019-08-27 14:49:23 -07:00
|
|
|
do {
|
2023-11-21 13:26:25 -08:00
|
|
|
COPY8(op, ip);
|
2019-09-19 13:25:03 -07:00
|
|
|
} while (op < oend);
|
|
|
|
} else {
|
|
|
|
assert(diff >= WILDCOPY_VECLEN || diff <= -WILDCOPY_VECLEN);
|
2020-01-28 20:37:04 -08:00
|
|
|
/* Separate out the first COPY16() call because the copy length is
|
2019-09-19 13:25:03 -07:00
|
|
|
* almost certain to be short, so the branches have different
|
2020-01-28 20:37:04 -08:00
|
|
|
* probabilities. Since it is almost certain to be short, only do
|
2020-04-02 23:08:13 +08:00
|
|
|
* one COPY16() in the first call. Then, do two calls per loop since
|
|
|
|
* at that point it is more likely to have a high trip count.
|
2019-09-19 13:25:03 -07:00
|
|
|
*/
|
2020-07-28 11:58:46 -07:00
|
|
|
ZSTD_copy16(op, ip);
|
2020-07-27 22:08:52 -07:00
|
|
|
if (16 >= length) return;
|
|
|
|
op += 16;
|
|
|
|
ip += 16;
|
2019-08-27 14:49:23 -07:00
|
|
|
do {
|
2019-09-19 13:25:03 -07:00
|
|
|
COPY16(op, ip);
|
2019-09-20 00:52:15 -07:00
|
|
|
COPY16(op, ip);
|
2019-08-27 14:49:23 -07:00
|
|
|
}
|
|
|
|
while (op < oend);
|
perf improvements for zstd decode (#1668)
* perf improvements for zstd decode
tldr: 7.5% average decode speedup on silesia corpus at compression levels 1-3 (sandy bridge)
Background: while investigating zstd perf differences between clang and gcc I noticed that even though gcc is vectorizing the loop in in wildcopy, it was not being done as well as could be done by hand. The sites where wildcopy is invoked have an interesting distribution of lengths to be copied. The loop trip count is rarely above 1, yet long copies are common enough to make their performance important.The code in zstd_decompress.c to invoke wildcopy handles the latter well but the gcc autovectorizer introduces a needlessly expensive startup check for vectorization.
See how GCC autovectorizes the loop here:
https://godbolt.org/z/apr0x0
Here is the code after this diff has been applied: (left hand side is the good one, right is with vectorizer on)
After: https://godbolt.org/z/OwO4F8
Note that autovectorization still does not do a good job on the optimized version, so it's turned off\
via attribute and flag. I found that neither attribute nor command-line flag were entirely successful in turning off vectorization, which is why there were both.
silesia benchmark data - second triad of each file is with the original code:
file orig compressedratio encode decode change
1#dickens 10192446-> 4268865(2.388), 198.9MB/s 709.6MB/s
2#dickens 10192446-> 3876126(2.630), 128.7MB/s 552.5MB/s
3#dickens 10192446-> 3682956(2.767), 104.6MB/s 537MB/s
1#dickens 10192446-> 4268865(2.388), 195.4MB/s 659.5MB/s 7.60%
2#dickens 10192446-> 3876126(2.630), 127MB/s 516.3MB/s 7.01%
3#dickens 10192446-> 3682956(2.767), 105MB/s 479.5MB/s 11.99%
1#mozilla 51220480-> 20117517(2.546), 285.4MB/s 734.9MB/s
2#mozilla 51220480-> 19067018(2.686), 220.8MB/s 686.3MB/s
3#mozilla 51220480-> 18508283(2.767), 152.2MB/s 669.4MB/s
1#mozilla 51220480-> 20117517(2.546), 283.4MB/s 697.9MB/s 5.30%
2#mozilla 51220480-> 19067018(2.686), 225.9MB/s 665MB/s 3.20%
3#mozilla 51220480-> 18508283(2.767), 154.5MB/s 640.6MB/s 4.50%
1#mr 9970564-> 3840242(2.596), 262.4MB/s 899.8MB/s
2#mr 9970564-> 3600976(2.769), 181.2MB/s 717.9MB/s
3#mr 9970564-> 3563987(2.798), 116.3MB/s 620MB/s
1#mr 9970564-> 3840242(2.596), 253.2MB/s 827.3MB/s 8.76%
2#mr 9970564-> 3600976(2.769), 177.4MB/s 655.4MB/s 9.54%
3#mr 9970564-> 3563987(2.798), 111.2MB/s 564.2MB/s 9.89%
1#nci 33553445-> 2849306(11.78), 575.2MB/s , 1335.8MB/s
2#nci 33553445-> 2890166(11.61), 509.3MB/s , 1238.1MB/s
3#nci 33553445-> 2857408(11.74), 431MB/s , 1210.7MB/s
1#nci 33553445-> 2849306(11.78), 565.4MB/s , 1220.2MB/s 9.47%
2#nci 33553445-> 2890166(11.61), 508.2MB/s , 1128.4MB/s 9.72%
3#nci 33553445-> 2857408(11.74), 429.1MB/s , 1097.7MB/s 10.29%
1#ooffice 6152192-> 3590954(1.713), 231.4MB/s , 662.6MB/s
2#ooffice 6152192-> 3323931(1.851), 162.8MB/s , 592.6MB/s
3#ooffice 6152192-> 3145625(1.956), 99.9MB/s , 549.6MB/s
1#ooffice 6152192-> 3590954(1.713), 224.7MB/s , 624.2MB/s 6.15%
2#ooffice 6152192-> 3323931 (1.851), 155MB/s , 564.5MB/s 4.98%
3#ooffice 6152192-> 3145625(1.956), 101.1MB/s , 521.2MB/s 5.45%
1#osdb 10085684-> 3739042(2.697), 271.9MB/s 876.4MB/s
2#osdb 10085684-> 3493875(2.887), 208.2MB/s 857MB/s
3#osdb 10085684-> 3515831(2.869), 135.3MB/s 805.4MB/s
1#osdb 10085684-> 3739042(2.697), 257.4MB/s 793.8MB/s 10.41%
2#osdb 10085684-> 3493875(2.887), 209.7MB/s 776.1MB/s 10.42%
3#osdb 10085684-> 3515831(2.869), 130.6MB/s 727.7MB/s 10.68%
1#reymont 6627202-> 2152771(3.078), 198.9MB/s 696.2MB/s
2#reymont 6627202-> 2071140(3.200), 170MB/s 595.2MB/s
3#reymont 6627202-> 1953597(3.392), 128.5MB/s 609.7MB/s
1#reymont 6627202-> 2152771(3.078), 199.6MB/s 655.2MB/s 6.26%
2#reymont 6627202-> 2071140(3.200), 168.2MB/s 554.4MB/s 7.36%
3#reymont 6627202-> 1953597(3.392), 128.7MB/s 557.4MB/s 9.38%
1#samba 21606400-> 5510994(3.921), 338.1MB/s 1066MB/s
2#samba 21606400-> 5240208(4.123), 258.7MB/s 992.3MB/s
3#samba 21606400-> 5003358(4.318), 200.2MB/s 991.1MB/s
1#samba 21606400-> 5510994(3.921), 330.8MB/s 974MB/s 9.45%
2#samba 21606400-> 5240208(4.123), 257.9MB/s 919.4MB/s 7.93%
3#samba 21606400-> 5003358(4.318), 198.5MB/s 908.9MB/s 9.04%
1#sao 7251944-> 6256401(1.159), 194.6MB/s 602.2MB/s
2#sao 7251944-> 5808761(1.248), 128.2MB/s 532.1MB/s
3#sao 7251944-> 5556318(1.305), 73MB/s 509.4MB/s
1#sao 7251944-> 6256401(1.159), 198.7MB/s 580.7MB/s 3.70%
2#sao 7251944-> 5808761(1.248), 129.1MB/s 502.7MB/s 5.85%
3#sao 7251944-> 5556318(1.305), 74.6MB/s 493.1MB/s 3.31%
1#webster 41458703-> 13692222(3.028), 222.3MB/s 752MB/s
2#webster 41458703-> 12842646(3.228), 157.6MB/s 532.2MB/s
3#webster 41458703-> 12191964(3.400), 124MB/s 468.5MB/s
1#webster 41458703-> 13692222(3.028), 219.7MB/s 697MB/s 7.89%
2#webster 41458703-> 12842646(3.228), 153.9MB/s 495.4MB/s 7.43%
3#webster 41458703-> 12191964(3.400), 124.8MB/s 444.8MB/s 5.33%
1#xml 5345280-> 696652(7.673), 485MB/s , 1333.9MB/s
2#xml 5345280-> 681492(7.843), 405.2MB/s , 1237.5MB/s
3#xml 5345280-> 639057(8.364), 328.5MB/s , 1281.3MB/s
1#xml 5345280-> 696652(7.673), 473.1MB/s , 1232.4MB/s 8.24%
2#xml 5345280-> 681492(7.843), 398.6MB/s , 1145.9MB/s 7.99%
3#xml 5345280-> 639057(8.364), 327.1MB/s , 1175MB/s 9.05%
1#x-ray 8474240-> 6772557(1.251), 521.3MB/s 762.6MB/s
2#x-ray 8474240-> 6684531(1.268), 230.5MB/s 688.5MB/s
3#x-ray 8474240-> 6166679(1.374), 68.7MB/s 478.8MB/s
1#x-ray 8474240-> 6772557(1.251), 502.8MB/s 736.7MB/s 3.52%
2#x-ray 8474240-> 6684531(1.268), 224.4MB/s 662MB/s 4.00%
3#x-ray 8474240-> 6166679(1.374), 67.3MB/s 437.8MB/s 9.37%
7.51%
* makefile changed to only pass -fno-tree-vectorize to gcc
* <Replace this line with a title. Use 1 line only, 67 chars or less>
Don't add "no-tree-vectorize" attribute on clang (which defines __GNUC__)
* fix for warning/error with subtraction of void* pointers
* fix c90 conformance issue - ISO C90 forbids mixed declarations and code
* Fix assert for negative diff, only when there is no overlap
* fix overflow revealed in fuzzing tests
* tweak for small speed increase
2019-07-11 15:31:07 -07:00
|
|
|
}
|
2016-08-08 00:44:00 +02:00
|
|
|
}
|
|
|
|
|
2020-04-07 11:02:06 +02:00
|
|
|
MEM_STATIC size_t ZSTD_limitCopy(void* dst, size_t dstCapacity, const void* src, size_t srcSize)
|
|
|
|
{
|
|
|
|
size_t const length = MIN(dstCapacity, srcSize);
|
|
|
|
if (length > 0) {
|
2020-08-10 12:46:38 -07:00
|
|
|
ZSTD_memcpy(dst, src, length);
|
2020-04-07 11:02:06 +02:00
|
|
|
}
|
|
|
|
return length;
|
|
|
|
}
|
2016-02-12 00:07:30 +01:00
|
|
|
|
2020-04-03 14:26:15 -07:00
|
|
|
/* define "workspace is too large" as this number of times larger than needed */
|
|
|
|
#define ZSTD_WORKSPACETOOLARGE_FACTOR 3
|
|
|
|
|
|
|
|
/* when workspace is continuously too large
|
|
|
|
* during at least this number of times,
|
|
|
|
* context's memory usage is considered wasteful,
|
|
|
|
* because it's sized to handle a worst case scenario which rarely happens.
|
|
|
|
* In which case, resize it down to free some memory */
|
|
|
|
#define ZSTD_WORKSPACETOOLARGE_MAXDURATION 128
|
|
|
|
|
2020-10-12 13:15:39 -07:00
|
|
|
/* Controls whether the input/output buffer is buffered or stable. */
|
|
|
|
typedef enum {
|
|
|
|
ZSTD_bm_buffered = 0, /* Buffer the input/output */
|
|
|
|
ZSTD_bm_stable = 1 /* ZSTD_inBuffer/ZSTD_outBuffer is stable */
|
|
|
|
} ZSTD_bufferMode_e;
|
|
|
|
|
2016-02-12 00:07:30 +01:00
|
|
|
|
|
|
|
/*-*******************************************
|
2017-11-07 15:27:06 -08:00
|
|
|
* Private declarations
|
2016-02-12 00:07:30 +01:00
|
|
|
*********************************************/
|
2016-07-29 21:22:17 +02:00
|
|
|
typedef struct seqDef_s {
|
2021-12-23 17:56:08 -08:00
|
|
|
U32 offBase; /* offBase == Offset + ZSTD_REP_NUM, or repcode 1,2,3 */
|
2016-07-29 21:22:17 +02:00
|
|
|
U16 litLength;
|
2021-12-23 13:39:46 -08:00
|
|
|
U16 mlBase; /* mlBase == matchLength - MINMATCH */
|
2016-07-29 21:22:17 +02:00
|
|
|
} seqDef;
|
|
|
|
|
2021-03-26 10:35:52 -07:00
|
|
|
/* Controls whether seqStore has a single "long" litLength or matchLength. See seqStore_t. */
|
|
|
|
typedef enum {
|
|
|
|
ZSTD_llt_none = 0, /* no longLengthType */
|
|
|
|
ZSTD_llt_literalLength = 1, /* represents a long literal */
|
|
|
|
ZSTD_llt_matchLength = 2 /* represents a long match */
|
|
|
|
} ZSTD_longLengthType_e;
|
|
|
|
|
2016-02-12 00:07:30 +01:00
|
|
|
typedef struct {
|
2016-07-30 00:55:13 +02:00
|
|
|
seqDef* sequencesStart;
|
2020-10-27 10:43:37 -04:00
|
|
|
seqDef* sequences; /* ptr to end of sequences */
|
2022-01-27 11:06:16 -08:00
|
|
|
BYTE* litStart;
|
|
|
|
BYTE* lit; /* ptr to end of literals */
|
|
|
|
BYTE* llCode;
|
|
|
|
BYTE* mlCode;
|
|
|
|
BYTE* ofCode;
|
2018-08-21 14:20:02 -07:00
|
|
|
size_t maxNbSeq;
|
2018-08-28 13:24:44 -07:00
|
|
|
size_t maxNbLit;
|
2020-10-27 10:43:37 -04:00
|
|
|
|
2021-03-26 10:35:52 -07:00
|
|
|
/* longLengthPos and longLengthType to allow us to represent either a single litLength or matchLength
|
2020-10-27 10:43:37 -04:00
|
|
|
* in the seqStore that has a value larger than U16 (if it exists). To do so, we increment
|
2021-03-15 14:46:26 -07:00
|
|
|
* the existing value of the litLength or matchLength by 0x10000.
|
2020-10-27 10:43:37 -04:00
|
|
|
*/
|
2022-01-29 16:23:21 -08:00
|
|
|
ZSTD_longLengthType_e longLengthType;
|
|
|
|
U32 longLengthPos; /* Index of the sequence to apply long length modification to */
|
2017-07-17 15:29:11 -07:00
|
|
|
} seqStore_t;
|
|
|
|
|
2020-05-01 16:11:47 -07:00
|
|
|
typedef struct {
|
|
|
|
U32 litLength;
|
|
|
|
U32 matchLength;
|
|
|
|
} ZSTD_sequenceLength;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the ZSTD_sequenceLength for the given sequences. It handles the decoding of long sequences
|
2021-03-26 10:35:52 -07:00
|
|
|
* indicated by longLengthPos and longLengthType, and adds MINMATCH back to matchLength.
|
2020-05-01 16:11:47 -07:00
|
|
|
*/
|
|
|
|
MEM_STATIC ZSTD_sequenceLength ZSTD_getSequenceLength(seqStore_t const* seqStore, seqDef const* seq)
|
|
|
|
{
|
|
|
|
ZSTD_sequenceLength seqLen;
|
|
|
|
seqLen.litLength = seq->litLength;
|
2021-12-23 13:39:46 -08:00
|
|
|
seqLen.matchLength = seq->mlBase + MINMATCH;
|
2020-05-01 16:11:47 -07:00
|
|
|
if (seqStore->longLengthPos == (U32)(seq - seqStore->sequencesStart)) {
|
2021-03-26 10:35:52 -07:00
|
|
|
if (seqStore->longLengthType == ZSTD_llt_literalLength) {
|
2022-08-03 11:28:39 -07:00
|
|
|
seqLen.litLength += 0x10000;
|
2020-05-01 16:11:47 -07:00
|
|
|
}
|
2021-03-26 10:35:52 -07:00
|
|
|
if (seqStore->longLengthType == ZSTD_llt_matchLength) {
|
2022-08-03 11:28:39 -07:00
|
|
|
seqLen.matchLength += 0x10000;
|
2020-05-01 16:11:47 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return seqLen;
|
|
|
|
}
|
|
|
|
|
2019-03-15 18:04:19 -07:00
|
|
|
/**
|
|
|
|
* Contains the compressed frame size and an upper-bound for the decompressed frame size.
|
2019-03-17 17:41:27 -07:00
|
|
|
* Note: before using `compressedSize`, check for errors using ZSTD_isError().
|
|
|
|
* similarly, before using `decompressedBound`, check for errors using:
|
|
|
|
* `decompressedBound != ZSTD_CONTENTSIZE_ERROR`
|
2019-03-15 18:04:19 -07:00
|
|
|
*/
|
|
|
|
typedef struct {
|
2023-01-11 18:14:40 -08:00
|
|
|
size_t nbBlocks;
|
2019-03-15 18:04:19 -07:00
|
|
|
size_t compressedSize;
|
|
|
|
unsigned long long decompressedBound;
|
2019-03-17 17:41:27 -07:00
|
|
|
} ZSTD_frameSizeInfo; /* decompress & legacy */
|
2019-03-15 18:04:19 -07:00
|
|
|
|
2017-11-07 15:27:06 -08:00
|
|
|
const seqStore_t* ZSTD_getSeqStore(const ZSTD_CCtx* ctx); /* compress & dictBuilder */
|
2023-01-27 12:04:29 -08:00
|
|
|
int ZSTD_seqToCodes(const seqStore_t* seqStorePtr); /* compress, dictBuilder, decodeCorpus (shouldn't get its definition from here) */
|
2015-10-29 16:49:43 +01:00
|
|
|
|
2016-06-03 14:53:51 +02:00
|
|
|
|
2017-01-19 10:32:55 -08:00
|
|
|
/* ZSTD_invalidateRepCodes() :
|
|
|
|
* ensures next compression will not use repcodes from previous block.
|
|
|
|
* Note : only works with regular variant;
|
|
|
|
* do not use with extDict variant ! */
|
2017-11-07 15:27:06 -08:00
|
|
|
void ZSTD_invalidateRepCodes(ZSTD_CCtx* cctx); /* zstdmt, adaptive_compression (shouldn't get this definition from here) */
|
|
|
|
|
2017-06-03 01:15:02 -07:00
|
|
|
|
2017-07-06 01:42:46 -07:00
|
|
|
typedef struct {
|
|
|
|
blockType_e blockType;
|
|
|
|
U32 lastBlock;
|
|
|
|
U32 origSize;
|
2018-10-25 16:28:41 -07:00
|
|
|
} blockProperties_t; /* declared here for decompress and fullbench */
|
2017-07-06 01:42:46 -07:00
|
|
|
|
|
|
|
/*! ZSTD_getcBlockSize() :
|
2017-11-08 11:05:32 -08:00
|
|
|
* Provides the size of compressed block from block header `src` */
|
fixed decoder behavior when nbSeqs==0 is encoded using 2 bytes
The sequence section starts with a number, which tells how sequences are present in the section.
If this number if 0, the section automatically ends.
The number 0 can be represented using the 1 byte or the 2 bytes formats.
That's because the 2-bytes formats fully overlaps the 1 byte format.
However, when 0 is represented using the 2-bytes format,
the decoder was expecting the sequence section to continue,
and was looking for FSE tables, which is incorrect.
Fixed this behavior, in both the reference decoder and the educational behavior.
In practice, this behavior never happens,
because the encoder will always select the 1-byte format to represent 0,
since this is more efficient.
Completed the fix with a new golden sample for tests,
a clarification of the specification,
and a decoder errata paragraph.
2023-06-05 16:03:00 -07:00
|
|
|
/* Used by: decompress, fullbench */
|
2017-07-06 01:42:46 -07:00
|
|
|
size_t ZSTD_getcBlockSize(const void* src, size_t srcSize,
|
|
|
|
blockProperties_t* bpPtr);
|
|
|
|
|
2018-10-25 16:28:41 -07:00
|
|
|
/*! ZSTD_decodeSeqHeaders() :
|
|
|
|
* decode sequence header from src */
|
fixed decoder behavior when nbSeqs==0 is encoded using 2 bytes
The sequence section starts with a number, which tells how sequences are present in the section.
If this number if 0, the section automatically ends.
The number 0 can be represented using the 1 byte or the 2 bytes formats.
That's because the 2-bytes formats fully overlaps the 1 byte format.
However, when 0 is represented using the 2-bytes format,
the decoder was expecting the sequence section to continue,
and was looking for FSE tables, which is incorrect.
Fixed this behavior, in both the reference decoder and the educational behavior.
In practice, this behavior never happens,
because the encoder will always select the 1-byte format to represent 0,
since this is more efficient.
Completed the fix with a new golden sample for tests,
a clarification of the specification,
and a decoder errata paragraph.
2023-06-05 16:03:00 -07:00
|
|
|
/* Used by: zstd_decompress_block, fullbench */
|
2018-10-25 16:28:41 -07:00
|
|
|
size_t ZSTD_decodeSeqHeaders(ZSTD_DCtx* dctx, int* nbSeqPtr,
|
|
|
|
const void* src, size_t srcSize);
|
|
|
|
|
2021-11-30 17:43:28 -08:00
|
|
|
/**
|
|
|
|
* @returns true iff the CPU supports dynamic BMI2 dispatch.
|
|
|
|
*/
|
|
|
|
MEM_STATIC int ZSTD_cpuSupportsBmi2(void)
|
|
|
|
{
|
|
|
|
ZSTD_cpuid_t cpuid = ZSTD_cpuid();
|
|
|
|
return ZSTD_cpuid_bmi1(cpuid) && ZSTD_cpuid_bmi2(cpuid);
|
|
|
|
}
|
2018-10-25 16:28:41 -07:00
|
|
|
|
2017-08-24 18:09:50 -07:00
|
|
|
#if defined (__cplusplus)
|
|
|
|
}
|
|
|
|
#endif
|
2017-07-06 01:42:46 -07:00
|
|
|
|
2015-10-29 16:49:43 +01:00
|
|
|
#endif /* ZSTD_CCOMMON_H_MODULE */
|