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

compressor: Allow to optionally use zlib-ng #12408

Merged
merged 50 commits into from
Aug 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
a6baa68
build: Add option to use zlib-ng as compression provider
dio Aug 1, 2020
eb6adb1
Test if zlib=ng works on CI
dio Aug 1, 2020
d73d356
ZLIB_COMPAT
dio Aug 1, 2020
d263984
Skip windows for now
dio Aug 1, 2020
6dc37c9
WITH_OPTIM off
dio Aug 1, 2020
7f55c63
Update doc
dio Aug 1, 2020
9c8a4ec
Strict compat, no optimization, no new strategies
dio Aug 1, 2020
4c89236
More comments
dio Aug 1, 2020
a92cc2b
Fix format
dio Aug 1, 2020
e7dae79
Limit to clang and fix asan
dio Aug 2, 2020
2c1cbdb
@bazel_tools//tools/cpp:clang constraint_values
dio Aug 2, 2020
d656fd5
zlib_ng_with_optimization too
dio Aug 2, 2020
6f41044
Fix gcc
dio Aug 2, 2020
6b490e6
zlib=ng
dio Aug 2, 2020
804dcff
Not sure if this is the fix
dio Aug 2, 2020
f172baf
Only for Linux:x86_64 for now
dio Aug 2, 2020
ce49e45
Checking on ARM64
dio Aug 2, 2020
49aeb5b
Remove turning on zlib-ng
dio Aug 3, 2020
101d208
Merge remote-tracking branch 'upstream/master'
dio Aug 4, 2020
cb13790
Review comments
dio Aug 4, 2020
c16ab8b
Merge remote-tracking branch 'upstream/master'
dio Aug 4, 2020
865b1ad
Update to tip and add 's'
dio Aug 5, 2020
97d36dc
Test handpicked zlib_ng_with_optimizations options
dio Aug 5, 2020
f2e42f4
Remove .
dio Aug 5, 2020
874c077
Make zlib=ng-with-optimizations optional
dio Aug 5, 2020
52a48cb
Merge remote-tracking branch
dio Aug 5, 2020
b565b01
Add compression/libraries section
dio Aug 13, 2020
34796a7
Merge remote-tracking branch 'upstream/master' into zlib-ng
dio Aug 13, 2020
12f6b3c
Merge remote-tracking branch 'upstream/master'
dio Aug 15, 2020
8b1c002
Add zlib=ng-with-optimizations to COMPILE_TIME_OPTIONS
dio Aug 19, 2020
9bb39da
Add comments
dio Aug 19, 2020
eddc6d8
Put at the end
dio Aug 19, 2020
44e4b2b
Fix comment
dio Aug 19, 2020
2c324d6
Fix
dio Aug 19, 2020
684571f
Bring back
dio Aug 19, 2020
bbf24eb
Merge remote-tracking branch 'upstream/master'
dio Aug 19, 2020
bbde62c
Add project metadata
dio Aug 19, 2020
87fe5ea
Missing s
dio Aug 19, 2020
04c930d
Use snake case
dio Aug 22, 2020
3cfd480
Remove zlib=ng_with_optimizations
dio Aug 24, 2020
500e6d5
Merge remote-tracking branch 'upstream/master'
dio Aug 24, 2020
25edeeb
Merge remote-tracking branch 'upstream/master'
dio Aug 25, 2020
008aec2
Attempt
dio Aug 26, 2020
046fd0d
Merge cache entries
dio Aug 26, 2020
0161406
Remove top level alias
dio Aug 26, 2020
71cbe99
Minimize the diff
dio Aug 26, 2020
cc9ab53
Trim
dio Aug 26, 2020
bf8ece6
grpc
dio Aug 26, 2020
ff08725
Fix
dio Aug 26, 2020
8a364a1
Fix format
dio Aug 26, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions bazel/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,14 @@ config_setting(
values = {"define": "boringssl=disabled"},
)

config_setting(
name = "zlib_ng",
mattklein123 marked this conversation as resolved.
Show resolved Hide resolved
constraint_values = [
"@bazel_tools//platforms:linux",
],
values = {"define": "zlib=ng"},
)

config_setting(
name = "enable_quiche",
values = {"define": "quiche=enabled"},
Expand Down
2 changes: 2 additions & 0 deletions bazel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,8 @@ The following optional features can be enabled on the Bazel build command-line:
* Process logging for Android applications can be enabled with `--define logger=android`.
* Excluding assertions for known issues with `--define disable_known_issue_asserts=true`.
A KNOWN_ISSUE_ASSERT is an assertion that should pass (like all assertions), but sometimes fails for some as-yet unidentified or unresolved reason. Because it is known to potentially fail, it can be compiled out even when DEBUG is true, when this flag is set. This allows Envoy to be run in production with assertions generally enabled, without crashing for known issues. KNOWN_ISSUE_ASSERT should only be used for newly-discovered issues that represent benign violations of expectations.
* Envoy can be linked to [`zlib-ng`](https://github.com/zlib-ng/zlib-ng) instead of
[`zlib`](https://zlib.net) with `--define zlib=ng`.

## Disabling extensions

Expand Down
26 changes: 25 additions & 1 deletion bazel/foreign_cc/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,32 @@ envoy_cmake_external(
"CMAKE_CXX_COMPILER_FORCED": "on",
"CMAKE_C_COMPILER_FORCED": "on",
"SKIP_BUILD_EXAMPLES": "on",

# The following entries are for zlib-ng. Since zlib and zlib-ng are compatible source
# codes and CMake ignores unknown cache entries, it is fine to combine it into one
# dictionary.
#
# Reference: https://github.com/zlib-ng/zlib-ng#build-options.
"ZLIB_COMPAT": "on",
"ZLIB_ENABLE_TESTS": "off",

# Warning: Turning WITH_OPTIM to "on" doesn't pass ZlibCompressorImplTest.CallingChecksum.
"WITH_OPTIM": "on",
# However turning off SSE4 fixes it.
"WITH_SSE4": "off",

# Warning: Turning WITH_NEW_STRATEGIES to "on" doesn't pass gzip compressor fuzz test.
# Turning this off means falling into NO_QUICK_STRATEGY route.
"WITH_NEW_STRATEGIES": "off",

# Only allow aligned address.
# Reference: https://github.com/zlib-ng/zlib-ng#advanced-build-options.
"UNALIGNED_OK": "off",
},
lib_source = "@net_zlib//:all",
lib_source = select({
"//bazel:zlib_ng": "@com_github_zlib_ng_zlib_ng//:all",
"//conditions:default": "@net_zlib//:all",
}),
static_libraries = select({
"//bazel:windows_x86_64": ["zlibstatic.lib"],
"//conditions:default": ["libz.a"],
Expand Down
7 changes: 7 additions & 0 deletions bazel/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ def envoy_dependencies(skip_targets = []):
_com_lightstep_tracer_cpp()
_io_opentracing_cpp()
_net_zlib()
_com_github_zlib_ng_zlib_ng()
_upb()
_proxy_wasm_cpp_sdk()
_proxy_wasm_cpp_host()
Expand Down Expand Up @@ -401,6 +402,12 @@ def _net_zlib():
actual = "@envoy//bazel/foreign_cc:zlib",
)

def _com_github_zlib_ng_zlib_ng():
_repository_impl(
name = "com_github_zlib_ng_zlib_ng",
build_file_content = BUILD_ALL_CONTENT,
)

def _com_google_cel_cpp():
_repository_impl("com_google_cel_cpp")
_repository_impl("rules_antlr")
Expand Down
11 changes: 11 additions & 0 deletions bazel/repository_locations.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,17 @@ DEPENDENCY_REPOSITORIES_SPEC = dict(
use_category = ["dataplane"],
cpe = "cpe:2.3:a:gnu:zlib:*",
),
com_github_zlib_ng_zlib_ng = dict(
project_name = "zlib-ng",
project_url = "https://github.com/zlib-ng/zlib-ng",
version = "193d8fd7dfb7927facab7a3034daa27ad5b9df1c",
sha256 = "5fe543e8d007b9e7b729f3d6b3a5ee1f9b68d0eef5f6af1393745a4dcd472a98",
strip_prefix = "zlib-ng-193d8fd7dfb7927facab7a3034daa27ad5b9df1c",
# 2020-08-16 develop branch.
urls = ["https://github.com/zlib-ng/zlib-ng/archive/193d8fd7dfb7927facab7a3034daa27ad5b9df1c.tar.gz"],
use_category = ["dataplane"],
cpe = "N/A",
),
com_github_jbeder_yaml_cpp = dict(
project_name = "yaml-cpp",
project_url = "https://github.com/jbeder/yaml-cpp",
Expand Down
1 change: 1 addition & 0 deletions ci/do_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ elif [[ "$CI_TARGET" == "bazel.compile_time_options" ]]; then
--define path_normalization_by_default=true \
--define deprecated_features=disabled \
--define use_new_codecs_in_integration_tests=true \
--define zlib=ng \
"
ENVOY_STDLIB="${ENVOY_STDLIB:-libstdc++}"
setup_clang_toolchain
Expand Down
1 change: 1 addition & 0 deletions docs/root/extending/extending.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ types including:
* BoringSSL private key methods
* :ref:`Watchdog action <envoy_v3_api_msg_config.bootstrap.v3.Watchdog.WatchdogAction>`
* :ref:`Internal redirect policy <envoy_v3_api_field_config.route.v3.InternalRedirectPolicy.predicates>`
* :ref:`Compression libraries <arch_overview_compression_libraries>`

As of this writing there is no high level extension developer documentation. The
:repo:`existing extensions <source/extensions>` are a good way to learn what is possible.
Expand Down
1 change: 1 addition & 0 deletions docs/root/intro/arch_overview/arch_overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Architecture overview
observability/observability
security/security
operations/operations
compression/libraries
other_features/other_features
other_protocols/other_protocols
advanced/advanced
19 changes: 19 additions & 0 deletions docs/root/intro/arch_overview/compression/libraries.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.. _arch_overview_compression_libraries:

Compression Libraries
=====================

Underlying implementation
-------------------------

Currently Envoy uses `zlib <http://zlib.net>`_ as a compression library.

.. note::

`zlib-ng <https://github.com/zlib-ng/zlib-ng>`_ is a fork that hosts several 3rd-party
contributions containing new optimizations. Those optimizations are considered useful for
`improving compression performance <https://github.com/envoyproxy/envoy/issues/8448#issuecomment-667152013>`_.
Envoy can be built to use `zlib-ng <https://github.com/zlib-ng/zlib-ng>`_ instead of regular
`zlib <http://zlib.net>`_ by using ``--define zlib=ng`` Bazel option. The relevant build options
used to build `zlib-ng <https://github.com/zlib-ng/zlib-ng>`_ can be evaluated in :repo:`here
<bazel/foreign_cc/BUILD>`. Currently, this option is only available on Linux.
1 change: 1 addition & 0 deletions docs/root/version_history/current.rst
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ New Features
* watchdog: support randomizing the watchdog's kill timeout to prevent synchronized kills via a maximium jitter parameter :ref:`max_kill_timeout_jitter<envoy_v3_api_field_config.bootstrap.v3.Watchdog.max_kill_timeout_jitter>`.
* watchdog: supports an extension point where actions can be registered to fire on watchdog events such as miss, megamiss, kill and multikill. See ref:`watchdog actions<envoy_v3_api_field_config.bootstrap.v3.Watchdog.actions>`.
* xds: added :ref:`extension config discovery<envoy_v3_api_msg_config.core.v3.ExtensionConfigSource>` support for HTTP filters.
* zlib: added option to use `zlib-ng <https://github.com/zlib-ng/zlib-ng>`_ as zlib library.

Deprecated
----------
Expand Down