Skip to content

Commit c5ac5fb

Browse files
committed
Use Jemalloc when possible
1 parent d79d567 commit c5ac5fb

File tree

6 files changed

+42
-8
lines changed

6 files changed

+42
-8
lines changed

.github/workflows/release.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,31 +22,31 @@ jobs:
2222
# Linux
2323
- name: Linux x86_64
2424
target: x86_64-unknown-linux-musl
25-
build-args: "--release"
25+
build-args: "--release --features=jemalloc"
2626

2727
- name: Linux x86
2828
target: i686-unknown-linux-musl
2929
build-args: "--release"
3030

3131
- name: Linux aarch64
3232
target: aarch64-unknown-linux-musl
33-
build-args: "--release"
33+
build-args: "--release --features=jemalloc"
3434

3535
- name: Linux armv7hf
3636
target: armv7-unknown-linux-musleabihf
3737
build-args: "--release"
3838

3939
- name: Freebsd x86_64
4040
target: x86_64-unknown-freebsd
41-
build-args: "--release"
41+
build-args: "--release --features=jemalloc"
4242

4343
- name: Freebsd x86
4444
target: i686-unknown-freebsd
4545
build-args: "--release"
4646

4747
- name: Android aarch64
4848
target: aarch64-linux-android
49-
build-args: "--release"
49+
build-args: "--release --features=jemalloc"
5050

5151
- name: Android armv7
5252
target: armv7-linux-androideabi
@@ -62,12 +62,12 @@ jobs:
6262
- name: MacOS x86_64
6363
os: macos-latest
6464
target: x86_64-apple-darwin
65-
build-args: "--release"
65+
build-args: "--release --features=jemalloc"
6666

6767
- name: MacOS aarch64
6868
os: macos-latest
6969
target: aarch64-apple-darwin
70-
build-args: "--release"
70+
build-args: "--release --features=jemalloc"
7171

7272
# - name: iOS x86_64
7373
# target: x86_64-apple-ios

Cargo.lock

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ ARG BIN_TARGET=--bins
3232
ARG PROFILE=release
3333

3434
#ENV RUSTFLAGS="-C link-arg=-Wl,--compress-debug-sections=zlib -C force-frame-pointers=yes"
35-
RUN cargo build --package=wstunnel-cli --profile=${PROFILE} ${BIN_TARGET}
35+
RUN cargo build --package=wstunnel-cli --features=jemalloc --profile=${PROFILE} ${BIN_TARGET}
3636

3737

3838
############################################################

justfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ make_release $VERSION $FORCE="":
1717
docker_release $TAG:
1818
#docker login -u erebe ghcr.io
1919
#~/.depot/bin/depot build --project v4z5w7md33 --platform linux/arm/v7,linux/arm64,linux/amd64 -t ghcr.io/erebe/wstunnel:$TAG -t ghcr.io/erebe/wstunnel:latest --push .
20-
docker buildx create --name builder --driver=kubernetes --platform=linux/arm64 '--driver-opt="nodeselector=kubernetes.io/arch=arm64","tolerations=key=kubernetes.io/hostname,value=server"' --node=build-arm64
20+
docker buildx create --name builder --driver=kubernetes --platform=linux/arm64 '--driver-opt="nodeselector=kubernetes.io/arch=arm64","tolerations=key=kubernetes.io/hostname,value=server","requests.cpu=16","requests.memory=16G"' --node=build-arm64
2121
docker buildx create --append --name builder --driver=kubernetes --platform=linux/amd64 '--driver-opt="nodeselector=kubernetes.io/arch=amd64","tolerations=key=kubernetes.io/hostname,value=toybox","requests.cpu=16","requests.memory=16G"' --node=build-amd64
2222
docker buildx use builder
2323
docker buildx build \

wstunnel-cli/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ tracing = { version = "0.1.41", features = ["log"] }
1212
tracing-subscriber = { version = "0.3.19", features = ["env-filter", "fmt", "local-time"] }
1313
wstunnel = { path = ".." , features = ["clap"] }
1414

15+
tikv-jemallocator = { version = "0.6", optional = true }
16+
17+
[features]
18+
default = []
19+
jemalloc = ["dep:tikv-jemallocator"]
20+
1521
[[bin]]
1622
name = "wstunnel"
1723
path = "src/main.rs"

wstunnel-cli/src/main.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ use wstunnel::config::{Client, Server};
88
use wstunnel::LocalProtocol;
99
use wstunnel::{run_client, run_server};
1010

11+
#[cfg(feature = "jemalloc")]
12+
use tikv_jemallocator::Jemalloc;
13+
14+
#[cfg(feature = "jemalloc")]
15+
#[global_allocator]
16+
static GLOBAL: Jemalloc = Jemalloc;
17+
1118
/// Use Websocket or HTTP2 protocol to tunnel {TCP,UDP} traffic
1219
/// wsTunnelClient <---> wsTunnelServer <---> RemoteHost
1320
#[derive(clap::Parser, Debug)]

0 commit comments

Comments
 (0)