Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zstd: introduce zstd compression support (backport to v3.2) #9891

Open
wants to merge 10 commits into
base: 3.2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,15 @@ add_subdirectory(${FLB_PATH_LIB_MPACK} EXCLUDE_FROM_ALL)
# Miniz (zip)
add_subdirectory(${FLB_PATH_LIB_MINIZ} EXCLUDE_FROM_ALL)

# Zstd (zstd)
set(ZSTD_BUILD_STATIC ON)
set(ZSTD_BUILD_SHARED OFF)
set(ZSTD_BUILD_COMPRESSION ON)
set(ZSTD_BUILD_DECOMPRESSION ON)
set(ZSTD_BUILD_DICTBUILDER OFF)
set(ZSTD_BUILD_DEPRECATED OFF)
add_subdirectory(${FLB_PATH_LIB_ZSTD}/build/cmake EXCLUDE_FROM_ALL)

# ring buffer library
add_subdirectory(${FLB_PATH_LIB_RING_BUFFER} EXCLUDE_FROM_ALL)

Expand Down
1 change: 1 addition & 0 deletions cmake/headers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ include_directories(
${FLB_PATH_ROOT_SOURCE}/${FLB_PATH_LIB_CTRACES}/include
${FLB_PATH_ROOT_SOURCE}/${FLB_PATH_LIB_CPROFILES}/include
${FLB_PATH_ROOT_SOURCE}/${FLB_PATH_LIB_RING_BUFFER}/lwrb/src/include
${FLB_PATH_ROOT_SOURCE}/${FLB_PATH_LIB_ZSTD}/lib

${CMAKE_CURRENT_BINARY_DIR}/${FLB_PATH_LIB_JANSSON}/include
${CMAKE_CURRENT_BINARY_DIR}/lib/cmetrics
Expand Down
1 change: 1 addition & 0 deletions cmake/libraries.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ set(FLB_PATH_LIB_SNAPPY "lib/snappy-fef67ac")
set(FLB_PATH_LIB_RDKAFKA "lib/librdkafka-2.4.0")
set(FLB_PATH_LIB_RING_BUFFER "lib/lwrb")
set(FLB_PATH_LIB_WASM_MICRO_RUNTIME "lib/wasm-micro-runtime-WAMR-1.3.3")
set(FLB_PATH_LIB_ZSTD "lib/zstd-1.5.6")
2 changes: 2 additions & 0 deletions include/fluent-bit/flb_http_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,8 @@ int flb_http_bearer_auth(struct flb_http_client *c,
const char *token);
int flb_http_set_keepalive(struct flb_http_client *c);
int flb_http_set_content_encoding_gzip(struct flb_http_client *c);
int flb_http_set_content_encoding_zstd(struct flb_http_client *c);

int flb_http_set_callback_context(struct flb_http_client *c,
struct flb_callback *cb_ctx);
int flb_http_set_response_test(struct flb_http_client *c, char *test_name,
Expand Down
29 changes: 29 additions & 0 deletions include/fluent-bit/flb_zstd.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */

/* Fluent Bit
* ==========
* Copyright (C) 2015-2024 The Fluent Bit Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef FLB_ZSTD_H
#define FLB_ZSTD_H

#include <fluent-bit/flb_info.h>
#include <zstd.h>

size_t flb_zstd_compress(void *in_data, size_t in_len, void **out_data, size_t *out_len);
size_t flb_zstd_uncompress(void *in_data, size_t in_len, void **out_data, size_t *out_len);

#endif
9 changes: 9 additions & 0 deletions lib/zstd-1.5.6/.buckconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[cxx]
cppflags = -DXXH_NAMESPACE=ZSTD_ -DZSTD_LEGACY_SUPPORT=4
cflags = -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow -Wstrict-aliasing=1 -Wswitch-enum -Wdeclaration-after-statement -Wstrict-prototypes -Wundef -Wpointer-arith
cxxppflags = -DXXH_NAMESPACE=ZSTD_ -DZSTD_LEGACY_SUPPORT=4
cxxflags = -std=c++11 -Wno-deprecated-declarations
gtest_dep = //contrib/pzstd:gtest

[httpserver]
port = 0
1 change: 1 addition & 0 deletions lib/zstd-1.5.6/.buckversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
c8dec2e8da52d483f6dd7c6cd2ad694e8e6fed2b
123 changes: 123 additions & 0 deletions lib/zstd-1.5.6/.circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
version: 2

jobs:
# the first half of the jobs are in this test
short-tests-0:
# TODO: Create a small custom docker image with all the dependencies we need
# preinstalled to reduce installation time.
docker:
- image: fbopensource/zstd-circleci-primary:0.0.1
steps:
- checkout
- run:
name: Test
command: |
./tests/test-license.py
cc -v
CFLAGS="-O0 -Werror -pedantic" make allmost; make clean
make c99build; make clean
make c11build; make clean
make -j regressiontest; make clean
make shortest; make clean
make cxxtest; make clean
# the second half of the jobs are in this test
short-tests-1:
docker:
- image: fbopensource/zstd-circleci-primary:0.0.1
steps:
- checkout
- run:
name: Test
command: |
make gnu90build; make clean
make gnu99build; make clean
make ppc64build V=1; make clean
make ppcbuild V=1; make clean
make armbuild V=1; make clean
make aarch64build V=1; make clean
make -C tests test-legacy test-longmatch; make clean
make -C lib libzstd-nomt; make clean
# This step should only be run in a cron job
regression-test:
docker:
- image: fbopensource/zstd-circleci-primary:0.0.1
environment:
CIRCLE_ARTIFACTS: /tmp/circleci-artifacts
steps:
- checkout
# Restore the cached resources.
- restore_cache:
# We try our best to bust the cache when the data changes by hashing
# data.c. If that doesn't work, simply update the version number here
# and below. If we fail to bust the cache, the regression testing will
# still work, since it has its own stamp, but will need to redownload
# everything.
keys:
- regression-cache-{{ checksum "tests/regression/data.c" }}-v0
- run:
name: Regression Test
command: |
make -C programs zstd
make -C tests/regression test
mkdir -p $CIRCLE_ARTIFACTS
./tests/regression/test \
--cache tests/regression/cache \
--output $CIRCLE_ARTIFACTS/results.csv \
--zstd programs/zstd
echo "NOTE: The new results.csv is uploaded as an artifact to this job"
echo " If this fails, go to the Artifacts pane in CircleCI, "
echo " download /tmp/circleci-artifacts/results.csv, and if they "
echo " are still good, copy it into the repo and commit it."
echo "> diff tests/regression/results.csv $CIRCLE_ARTIFACTS/results.csv"
diff tests/regression/results.csv $CIRCLE_ARTIFACTS/results.csv
# Only save the cache on success (default), since if the failure happened
# before we stamp the data cache, we will have a bad cache for this key.
- save_cache:
key: regression-cache-{{ checksum "tests/regression/data.c" }}-v0
paths:
- tests/regression/cache
- store_artifacts:
path: /tmp/circleci-artifacts


workflows:
version: 2
commit:
jobs:
# Run the tests in parallel
- short-tests-0
- short-tests-1
- regression-test

nightly:
triggers:
- schedule:
cron: "0 0 * * *"
filters:
branches:
only:
- release
- dev
- master
jobs:
# Run daily regression tests
- regression-test



# Longer tests
#- make -C tests test-zstd-nolegacy && make clean
#- pyenv global 3.4.4; make -C tests versionsTest && make clean
#- make zlibwrapper && make clean
#- gcc -v; make -C tests test32 MOREFLAGS="-I/usr/include/x86_64-linux-gnu" && make clean
#- make uasan && make clean
#- make asan32 && make clean
#- make -C tests test32 CC=clang MOREFLAGS="-g -fsanitize=address -I/usr/include/x86_64-linux-gnu"
# Valgrind tests
#- CFLAGS="-O1 -g" make -C zlibWrapper valgrindTest && make clean
#- make -C tests valgrindTest && make clean
# ARM, AArch64, PowerPC, PowerPC64 tests
#- make ppctest && make clean
#- make ppc64test && make clean
#- make armtest && make clean
#- make aarch64test && make clean
9 changes: 9 additions & 0 deletions lib/zstd-1.5.6/.circleci/images/primary/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM circleci/buildpack-deps@sha256:f6f10c11b7b8ccfd4f4a5b830c3256803604ce61292b60cb22e26b12f62b0e8c

RUN sudo dpkg --add-architecture i386

Check failure on line 3 in lib/zstd-1.5.6/.circleci/images/primary/Dockerfile

View workflow job for this annotation

GitHub Actions / hadolint

[hadolint] lib/zstd-1.5.6/.circleci/images/primary/Dockerfile#L3 <DL3004>(https://github.com/hadolint/hadolint/wiki/DL3004)

Do not use sudo as it leads to unpredictable behavior. Use a tool like gosu to enforce root
Raw output
message:"Do not use sudo as it leads to unpredictable behavior. Use a tool like gosu to enforce root" location:{path:"lib/zstd-1.5.6/.circleci/images/primary/Dockerfile" range:{start:{line:3 column:1}}} severity:ERROR source:{name:"hadolint" url:"https://github.com/hadolint/hadolint"} code:{value:"DL3004" url:"https://github.com/hadolint/hadolint/wiki/DL3004"}
RUN sudo apt-get -y -qq update

Check failure on line 4 in lib/zstd-1.5.6/.circleci/images/primary/Dockerfile

View workflow job for this annotation

GitHub Actions / hadolint

[hadolint] lib/zstd-1.5.6/.circleci/images/primary/Dockerfile#L4 <DL3004>(https://github.com/hadolint/hadolint/wiki/DL3004)

Do not use sudo as it leads to unpredictable behavior. Use a tool like gosu to enforce root
Raw output
message:"Do not use sudo as it leads to unpredictable behavior. Use a tool like gosu to enforce root" location:{path:"lib/zstd-1.5.6/.circleci/images/primary/Dockerfile" range:{start:{line:4 column:1}}} severity:ERROR source:{name:"hadolint" url:"https://github.com/hadolint/hadolint"} code:{value:"DL3004" url:"https://github.com/hadolint/hadolint/wiki/DL3004"}

Check notice on line 4 in lib/zstd-1.5.6/.circleci/images/primary/Dockerfile

View workflow job for this annotation

GitHub Actions / hadolint

[hadolint] lib/zstd-1.5.6/.circleci/images/primary/Dockerfile#L4 <DL3059>(https://github.com/hadolint/hadolint/wiki/DL3059)

Multiple consecutive `RUN` instructions. Consider consolidation.
Raw output
message:"Multiple consecutive `RUN` instructions. Consider consolidation." location:{path:"lib/zstd-1.5.6/.circleci/images/primary/Dockerfile" range:{start:{line:4 column:1}}} severity:INFO source:{name:"hadolint" url:"https://github.com/hadolint/hadolint"} code:{value:"DL3059" url:"https://github.com/hadolint/hadolint/wiki/DL3059"}
RUN sudo apt-get -y install \

Check failure on line 5 in lib/zstd-1.5.6/.circleci/images/primary/Dockerfile

View workflow job for this annotation

GitHub Actions / hadolint

[hadolint] lib/zstd-1.5.6/.circleci/images/primary/Dockerfile#L5 <DL3004>(https://github.com/hadolint/hadolint/wiki/DL3004)

Do not use sudo as it leads to unpredictable behavior. Use a tool like gosu to enforce root
Raw output
message:"Do not use sudo as it leads to unpredictable behavior. Use a tool like gosu to enforce root" location:{path:"lib/zstd-1.5.6/.circleci/images/primary/Dockerfile" range:{start:{line:5 column:1}}} severity:ERROR source:{name:"hadolint" url:"https://github.com/hadolint/hadolint"} code:{value:"DL3004" url:"https://github.com/hadolint/hadolint/wiki/DL3004"}

Check notice on line 5 in lib/zstd-1.5.6/.circleci/images/primary/Dockerfile

View workflow job for this annotation

GitHub Actions / hadolint

[hadolint] lib/zstd-1.5.6/.circleci/images/primary/Dockerfile#L5 <DL3059>(https://github.com/hadolint/hadolint/wiki/DL3059)

Multiple consecutive `RUN` instructions. Consider consolidation.
Raw output
message:"Multiple consecutive `RUN` instructions. Consider consolidation." location:{path:"lib/zstd-1.5.6/.circleci/images/primary/Dockerfile" range:{start:{line:5 column:1}}} severity:INFO source:{name:"hadolint" url:"https://github.com/hadolint/hadolint"} code:{value:"DL3059" url:"https://github.com/hadolint/hadolint/wiki/DL3059"}
gcc-multilib-powerpc-linux-gnu gcc-arm-linux-gnueabi \
libc6-dev-armel-cross gcc-aarch64-linux-gnu libc6-dev-arm64-cross \
libc6-dev-ppc64-powerpc-cross zstd gzip coreutils \
libcurl4-openssl-dev
10 changes: 10 additions & 0 deletions lib/zstd-1.5.6/.cirrus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
task:
name: FreeBSD (shortest)
freebsd_instance:
matrix:
image_family: freebsd-14-0
image_family: freebsd-13-2
install_script: pkg install -y gmake coreutils
script: |
MOREFLAGS="-Werror" gmake -j all
gmake shortest
21 changes: 21 additions & 0 deletions lib/zstd-1.5.6/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Set the default behavior
* text eol=lf

# Explicitly declare source files
*.c text eol=lf
*.h text eol=lf

# Denote files that should not be modified.
*.odt binary
*.png binary

# Visual Studio
*.sln text eol=crlf
*.vcxproj* text eol=crlf
*.vcproj* text eol=crlf
*.suo binary
*.rc text eol=crlf

# Windows
*.bat text eol=crlf
*.cmd text eol=crlf
35 changes: 35 additions & 0 deletions lib/zstd-1.5.6/.github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Downloads data '...'
2. Run '...' with flags '...'
3. Scroll up on the log to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots and charts**
If applicable, add screenshots and charts to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. Mac]
- Version [e.g. 22]
- Compiler [e.g. gcc]
- Flags [e.g. O2]
- Other relevant hardware specs [e.g. Dual-core]
- Build system [e.g. Makefile]

**Additional context**
Add any other context about the problem here.
20 changes: 20 additions & 0 deletions lib/zstd-1.5.6/.github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
6 changes: 6 additions & 0 deletions lib/zstd-1.5.6/.github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
Loading