From b7f646e8b285e0813820300a6d83865d131b27f5 Mon Sep 17 00:00:00 2001 From: Olasoji Date: Thu, 23 Oct 2025 14:46:58 -0700 Subject: [PATCH 1/7] Adds test to validate log_stats_samples config Signed-off-by: Olasoji --- tests/zlib_accel_test.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/zlib_accel_test.cpp b/tests/zlib_accel_test.cpp index 6d66f9c..33d024a 100644 --- a/tests/zlib_accel_test.cpp +++ b/tests/zlib_accel_test.cpp @@ -1231,6 +1231,7 @@ void CreateAndWriteTempConfigFile(const char* file_path) { temp_file << "use_zlib_compress=!0222\n"; temp_file << "use_zlib_uncompress=AB23\n"; temp_file << "log_level=10\n"; + temp_file << "log_stats_samples=4294967296\n"; temp_file.close(); } @@ -1243,6 +1244,7 @@ TEST_F(ConfigLoaderTest, LoadInvalidConfig) { uint32_t DEFAULT_ZLIB_COMPRESS = GetConfig(USE_ZLIB_COMPRESS); uint32_t DEFAULT_ZLIB_UNCOMPRESS = GetConfig(USE_ZLIB_UNCOMPRESS); uint32_t DEFAULT_LOG_LEVEL = GetConfig(LOG_LEVEL); + uint32_t DEFAULT_LOG_STATS_SAMPLES = GetConfig(LOG_STATS_SAMPLES); CreateAndWriteTempConfigFile("/tmp/invalid_config"); EXPECT_TRUE(LoadConfigFile(file_content, "/tmp/invalid_config")); @@ -1253,6 +1255,7 @@ TEST_F(ConfigLoaderTest, LoadInvalidConfig) { EXPECT_EQ(GetConfig(USE_ZLIB_COMPRESS), DEFAULT_ZLIB_COMPRESS); EXPECT_EQ(GetConfig(USE_ZLIB_UNCOMPRESS), DEFAULT_ZLIB_UNCOMPRESS); EXPECT_EQ(GetConfig(LOG_LEVEL), DEFAULT_LOG_LEVEL); + EXPECT_EQ(GetConfig(LOG_STATS_SAMPLES), DEFAULT_LOG_STATS_SAMPLES); std::remove("/tmp/invalid_config"); // Restore config from official config file LoadConfigFile(file_content); From db531ffb6db578628a824b90fbe685dcc6ad0e41 Mon Sep 17 00:00:00 2001 From: Olasoji Date: Wed, 17 Dec 2025 16:01:34 -0800 Subject: [PATCH 2/7] Reduces excessive error logging in QAT mode Signed-off-by: Olasoji --- qat.cpp | 1 + qat.h | 2 ++ zlib_accel.cpp | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/qat.cpp b/qat.cpp index 2ef4c0c..d5bc57e 100644 --- a/qat.cpp +++ b/qat.cpp @@ -100,6 +100,7 @@ void QATJob::Init(QzSessionPtr &qzSession, CompressedFormat format, } // Initialize QAT hardware + qzSetLogLevel(LOG_NONE); int status = qzInit(session.get(), 0); if (status != QZ_OK && status != QZ_DUPLICATE) { Log(LogLevel::LOG_ERROR, "qzInit() failure Line ", __LINE__, " session ", diff --git a/qat.h b/qat.h index 3a04045..f81285e 100644 --- a/qat.h +++ b/qat.h @@ -14,6 +14,8 @@ #define VISIBLE_FOR_TESTING __attribute__((visibility("default"))) +inline constexpr unsigned int QAT_DEST_BUFFER_MIN_SIZE = 512; + inline constexpr unsigned int QAT_HW_BUFF_SZ = QZ_HW_BUFF_MAX_SZ; class QATJob { diff --git a/zlib_accel.cpp b/zlib_accel.cpp index e260841..018f7e1 100644 --- a/zlib_accel.cpp +++ b/zlib_accel.cpp @@ -297,6 +297,7 @@ int ZEXPORT deflate(z_streamp strm, int flush) { #ifdef USE_QAT qat_available = configs[USE_QAT_COMPRESS] && + output_len >= QAT_DEST_BUFFER_MIN_SIZE && SupportedOptionsQAT(deflate_settings->window_bits, input_len); #endif @@ -1352,7 +1353,6 @@ int ZEXPORT gzeof(gzFile file) { GzipFile* gz = gzip_files.Get(file); return gz->reached_eof; } - #if defined(__clang__) #pragma clang attribute pop #endif From 5d513a4659e427d39a2d419dc645763abb0b36c7 Mon Sep 17 00:00:00 2001 From: Olasoji Date: Wed, 17 Dec 2025 16:05:22 -0800 Subject: [PATCH 3/7] Bugfix for the log stream Signed-off-by: Olasoji --- logging.h | 1 + 1 file changed, 1 insertion(+) diff --git a/logging.h b/logging.h index 7b74d9f..b5e8301 100644 --- a/logging.h +++ b/logging.h @@ -61,6 +61,7 @@ inline void Log(LogLevel level, Args&&... args) { } std::ostream& stream = GetLogStream(); + stream << std::dec; switch (level) { case LogLevel::LOG_ERROR: stream << "Error: "; From 9aff4f8c50af5b3bd3ae92c24af17848a8338ccd Mon Sep 17 00:00:00 2001 From: Olasoji Date: Wed, 17 Dec 2025 16:07:54 -0800 Subject: [PATCH 4/7] Treats QPL_STS_MORE_OUTPUT_NEEDED as a non error condition for IAA Signed-off-by: Olasoji --- iaa.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iaa.cpp b/iaa.cpp index 1ec6fe2..2e0ca66 100644 --- a/iaa.cpp +++ b/iaa.cpp @@ -218,7 +218,7 @@ int UncompressIAA(uint8_t* input, uint32_t* input_length, uint8_t* output, job->dictionary = nullptr; qpl_status status = qpl_execute_job(job); - if (status != QPL_STS_OK) { + if (status != QPL_STS_OK && status != QPL_STS_MORE_OUTPUT_NEEDED) { Log(LogLevel::LOG_ERROR, "UncompressIAA() Line ", __LINE__, " qpl_execute_job status ", status, "\n"); return 1; From 806ce1dd91df3e071b1f1108a5b54a61754e70d0 Mon Sep 17 00:00:00 2001 From: Olasoji Date: Thu, 18 Dec 2025 11:11:30 -0800 Subject: [PATCH 5/7] Fixed formatting Signed-off-by: Olasoji --- zlib_accel.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/zlib_accel.cpp b/zlib_accel.cpp index 018f7e1..72c5105 100644 --- a/zlib_accel.cpp +++ b/zlib_accel.cpp @@ -296,8 +296,7 @@ int ZEXPORT deflate(z_streamp strm, int flush) { #endif #ifdef USE_QAT qat_available = - configs[USE_QAT_COMPRESS] && - output_len >= QAT_DEST_BUFFER_MIN_SIZE && + configs[USE_QAT_COMPRESS] && output_len >= QAT_DEST_BUFFER_MIN_SIZE && SupportedOptionsQAT(deflate_settings->window_bits, input_len); #endif From 5bdec2c37cfa6a34c9ae6d30cc66b6af2a8ad64b Mon Sep 17 00:00:00 2001 From: Olasoji Date: Tue, 10 Mar 2026 10:36:03 -0700 Subject: [PATCH 6/7] - Modifies iaa behavior so that when QPL_STS_MORE_OUTPUT_NEEDED is returned eos isnt erronously set. Signed-off-by: Olasoji --- iaa.cpp | 7 +++++-- zlib_accel.cpp | 8 ++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/iaa.cpp b/iaa.cpp index 2e0ca66..8b80ade 100644 --- a/iaa.cpp +++ b/iaa.cpp @@ -230,9 +230,12 @@ int UncompressIAA(uint8_t* input, uint32_t* input_length, uint8_t* output, if (gzip_ext) { *input_length = gzip_ext_dest_size + GZIP_EXT_HDRFTR_SIZE; } - *end_of_stream = true; + // IAA decompression is stateless in this wrapper; when more output is needed + // the caller must continue via zlib path. + *end_of_stream = (status == QPL_STS_OK); Log(LogLevel::LOG_INFO, "UncompressIAA() Line ", __LINE__, " output size ", - job->total_out, "\n"); + job->total_out, ", status ", status, ", end_of_stream ", + *end_of_stream, "\n"); return 0; } diff --git a/zlib_accel.cpp b/zlib_accel.cpp index 72c5105..26188e7 100644 --- a/zlib_accel.cpp +++ b/zlib_accel.cpp @@ -489,6 +489,11 @@ int ZEXPORT inflate(z_streamp strm, int flush) { &output_len, qpl_path_hardware, inflate_settings->window_bits, &end_of_stream); inflate_settings->path = IAA; + // IAA inflate is stateless in this wrapper. If stream end was not + // reached, use zlib for stateful continuation. + if (!end_of_stream) { + ret = 1; + } in_call = false; INCREMENT_STAT(INFLATE_IAA_COUNT); INCREMENT_STAT_COND(ret != 0, INFLATE_IAA_ERROR_COUNT); @@ -681,6 +686,9 @@ int ZEXPORT uncompress2(Bytef* dest, uLongf* destLen, const Bytef* source, in_call = true; ret = UncompressIAA(const_cast(source), &input_len, dest, &output_len, qpl_path_hardware, 15, &end_of_stream); + if (!end_of_stream) { + ret = 1; + } in_call = false; #endif // USE_IAA } else if (path_selected == QAT) { From 25434615075690283eab3fc6e4d323fbdf3c542f Mon Sep 17 00:00:00 2001 From: Olasoji Date: Tue, 10 Mar 2026 10:47:52 -0700 Subject: [PATCH 7/7] -Adds proper formatting Signed-off-by: Olasoji --- iaa.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iaa.cpp b/iaa.cpp index 8b80ade..2bbcd27 100644 --- a/iaa.cpp +++ b/iaa.cpp @@ -234,8 +234,8 @@ int UncompressIAA(uint8_t* input, uint32_t* input_length, uint8_t* output, // the caller must continue via zlib path. *end_of_stream = (status == QPL_STS_OK); Log(LogLevel::LOG_INFO, "UncompressIAA() Line ", __LINE__, " output size ", - job->total_out, ", status ", status, ", end_of_stream ", - *end_of_stream, "\n"); + job->total_out, ", status ", status, ", end_of_stream ", *end_of_stream, + "\n"); return 0; }