代码拉取完成,页面将自动刷新
同步操作将从 OpenCloudOS Stream/qatzip 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From 49bcf697305ee71f954e2f08883fa18bcc689f5e Mon Sep 17 00:00:00 2001
From: XingHongChenIntel <xinghong.chen@intel.com>
Date: Wed, 12 Apr 2023 18:04:31 -0400
Subject: [PATCH] QATAPP-29019: Improve sw fallback performance
*Change lz4 sw fallback compression API to 'LZ4F_compressFrame'
*fix gzip sw fallback comp level bypass, and remove session limitation
Signed-off-by: XingHongChenIntel <xinghong.chen@intel.com>
---
configure.ac | 2 +-
src/qatzip_internal.h | 1 -
src/qatzip_sw.c | 80 +++----------------------------------------
src/qatzip_utils.c | 1 -
4 files changed, 6 insertions(+), 78 deletions(-)
diff --git a/configure.ac b/configure.ac
index 571184f..174b0df 100644
--- a/configure.ac
+++ b/configure.ac
@@ -105,7 +105,7 @@ AC_CHECK_LIB([z], [deflate], , AC_MSG_ERROR([deflate not found]))
#check for lz4 lib
AC_CHECK_HEADER([lz4.h], , [AC_MSG_ERROR([lz4.h not found])])
AC_CHECK_HEADER([lz4frame.h], , [AC_MSG_ERROR([lz4frame.h not found])])
-AC_CHECK_LIB([lz4], [LZ4F_compressBegin], , AC_MSG_ERROR([LZ4F_compressBegin not found]))
+AC_CHECK_LIB([lz4], [LZ4F_compressFrame], , AC_MSG_ERROR([LZ4F_compressFrame not found]))
##check for xxhash lib
#AC_CHECK_HEADER([xxhash.h],,[AC_MSG_ERROR([not found xxhash.h])])
diff --git a/src/qatzip_internal.h b/src/qatzip_internal.h
index 3bd2d40..b328a4a 100755
--- a/src/qatzip_internal.h
+++ b/src/qatzip_internal.h
@@ -305,7 +305,6 @@ typedef struct QzSess_S {
z_stream *deflate_strm;
DeflateState_T deflate_stat;
- LZ4F_cctx *cctx;
LZ4F_dctx *dctx;
} QzSess_T;
diff --git a/src/qatzip_sw.c b/src/qatzip_sw.c
index 50a40df..b2b4cf0 100755
--- a/src/qatzip_sw.c
+++ b/src/qatzip_sw.c
@@ -106,8 +106,7 @@ int qzDeflateSWCompress(QzSession_T *sess, const unsigned char *src,
qz_sess = (QzSess_T *) sess->internal;
qz_sess->force_sw = 1;
- comp_level = (qz_sess->sess_params.comp_lvl == Z_BEST_COMPRESSION) ? \
- Z_BEST_COMPRESSION : Z_DEFAULT_COMPRESSION;
+ comp_level = qz_sess->sess_params.comp_lvl;
data_fmt = qz_sess->sess_params.data_fmt;
chunk_sz = qz_sess->sess_params.hw_buff_sz;
stream = qz_sess->deflate_strm;
@@ -431,80 +430,15 @@ int qzLZ4SWCompress(QzSession_T *sess, const unsigned char *src,
unsigned int *src_len, unsigned char *dest,
unsigned int *dest_len, unsigned int last)
{
- unsigned int chunk_sz = 0;
- size_t total_in = 0, total_out = 0;
- size_t current_loop_in = 0;
- size_t left_input_sz = *src_len;
- size_t left_output_sz = *dest_len;
- QzSess_T *qz_sess = NULL;
- LZ4F_preferences_t preferences;
- LZ4F_cctx *cctx;
- size_t ret = 0;
-
+ size_t total_out = 0;
assert(sess);
assert(sess->internal);
- qz_sess = (QzSess_T *) sess->internal;
- if (qz_sess->cctx == NULL) {
- ret = LZ4F_createCompressionContext(&(qz_sess->cctx), LZ4F_VERSION);
- if (LZ4F_isError(ret)) {
- QZ_ERROR("LZ4F_createCompressionContext error: %s\n", LZ4F_getErrorName(ret));
- goto lz4_compress_fail;
- }
-
- qzMemSet(&preferences, 0, sizeof(LZ4F_preferences_t));
- preferences.frameInfo.blockMode = 0;
- preferences.frameInfo.blockChecksumFlag = 0;
- preferences.frameInfo.contentChecksumFlag = 1;
- preferences.frameInfo.contentSize = left_input_sz;
- preferences.autoFlush = 1;
- preferences.compressionLevel = qz_sess->sess_params.comp_lvl;
-
- /* LZ4F_compressBegin will create frame header into dest buffer. */
- ret = LZ4F_compressBegin(qz_sess->cctx, dest, left_output_sz, &preferences);
- if (LZ4F_isError(ret)) {
- QZ_ERROR("LZ4F_compressBegin error: %s\n", LZ4F_getErrorName(ret));
- goto lz4_compress_fail;
- }
- total_out += ret;
- left_output_sz -= ret;
- dest += ret;
-
- }
-
- cctx = qz_sess->cctx;
- chunk_sz = qz_sess->sess_params.hw_buff_sz;
- do {
- current_loop_in = chunk_sz < left_input_sz ? chunk_sz : left_input_sz;
- ret = LZ4F_compressUpdate(cctx, (void *)dest, left_output_sz,
- (const void *)src, current_loop_in, NULL);
- if (LZ4F_isError(ret)) {
- QZ_ERROR("LZ4F_compressUpdate error: %s\n", LZ4F_getErrorName(ret));
- goto lz4_compress_fail;
- }
- src += current_loop_in;
- dest += ret;
- left_output_sz -= ret;
- left_input_sz -= current_loop_in;
- total_out += ret;
- total_in += current_loop_in;
-
- } while (left_input_sz > 0);
-
- /* Call LZ4F_compressEnd to finish an lz4 frame, wirte an endmark and a checksum
- * to dest buffer. */
- ret = LZ4F_compressEnd(cctx, (void *)dest, left_output_sz,
- NULL);
- if (LZ4F_isError(ret)) {
- QZ_ERROR("LZ4F_compressEnd error: %s\n", LZ4F_getErrorName(ret));
+ total_out = LZ4F_compressFrame(dest, *dest_len, src, *src_len, NULL);
+ if (LZ4F_isError(total_out)) {
+ QZ_ERROR("LZ4F_compressUpdate error: %s\n", LZ4F_getErrorName(total_out));
goto lz4_compress_fail;
}
- total_out += ret;
-
- LZ4F_freeCompressionContext(qz_sess->cctx);
- qz_sess->cctx = NULL;
-
- *src_len = total_in;
*dest_len = total_out;
QZ_DEBUG("Exit qzLZ4SWCompress: src_len %u dest_len %u\n",
*src_len, *dest_len);
@@ -512,10 +446,6 @@ int qzLZ4SWCompress(QzSession_T *sess, const unsigned char *src,
return QZ_OK;
lz4_compress_fail:
- if (qz_sess->cctx != NULL) {
- LZ4F_freeCompressionContext(qz_sess->cctx);
- qz_sess->cctx = NULL;
- }
*src_len = 0;
*dest_len = 0;
return QZ_FAIL;
diff --git a/src/qatzip_utils.c b/src/qatzip_utils.c
index a40581f..ffc3a1e 100644
--- a/src/qatzip_utils.c
+++ b/src/qatzip_utils.c
@@ -286,7 +286,6 @@ int qzSetupSessionInternal(QzSession_T *sess)
qz_sess->inflate_stat = InflateNull;
qz_sess->deflate_strm = NULL;
qz_sess->deflate_stat = DeflateNull;
- qz_sess->cctx = NULL;
qz_sess->dctx = NULL;
if (g_process.qz_init_status != QZ_OK) {
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。