Skip to content

Commit 85e94c7

Browse files
committed
Add WITH_LIBDEFLATE
1 parent 9a3249d commit 85e94c7

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@
1010
[submodule "h1spec"]
1111
path = h1spec
1212
url = https://github.com/uNetworking/h1spec
13+
[submodule "libdeflate"]
14+
path = libdeflate
15+
url = ./libdeflate

build.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ int main(int argc, char **argv) {
1515
strcat(CXXFLAGS, " -march=native -O3 -Wpedantic -Wall -Wextra -Wsign-conversion -Wconversion -std=c++20 -Isrc -IuSockets/src");
1616
strcat(LDFLAGS, " uSockets/*.o");
1717

18+
// We can use libdeflate as a fast path to zlib (you need to build it first)
19+
if (env_is("WITH_LIBDEFLATE", "1")) {
20+
strcat(LDFLAGS, " libdeflate/libdeflate.a");
21+
strcat(CXXFLAGS, " -DUWS_USE_LIBDEFLATE -I libdeflate");
22+
}
23+
1824
// By default we use LTO, but Windows does not support it
1925
if (!env_is("WITH_LTO", "0")) {
2026
strcat(CXXFLAGS, " -flto=auto");

examples/EchoServer.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ int main() {
1919
.passphrase = "1234"
2020
}).ws<PerSocketData>("/*", {
2121
/* Settings */
22-
.compression = uWS::CompressOptions(uWS::DEDICATED_COMPRESSOR_4KB | uWS::DEDICATED_DECOMPRESSOR),
22+
.compression = uWS::CompressOptions(uWS::DEDICATED_COMPRESSOR | uWS::SHARED_DECOMPRESSOR),
2323
.maxPayloadLength = 100 * 1024 * 1024,
2424
.idleTimeout = 16,
2525
.maxBackpressure = 100 * 1024 * 1024,
@@ -36,7 +36,9 @@ int main() {
3636
/* This is the opposite of what you probably want; compress if message is LARGER than 16 kb
3737
* the reason we do the opposite here; compress if SMALLER than 16 kb is to allow for
3838
* benchmarking of large message sending without compression */
39-
ws->send(message, opCode, message.length() < 16 * 1024);
39+
40+
/* Never mind, it changed back to never compressing for now */
41+
ws->send(message, opCode, false);
4042
},
4143
.dropped = [](auto */*ws*/, std::string_view /*message*/, uWS::OpCode /*opCode*/) {
4244
/* A message was dropped due to set maxBackpressure and closeOnBackpressureLimit limit */

libdeflate

Submodule libdeflate added at 8d351ab

0 commit comments

Comments
 (0)