Skip to content

Commit 447557b

Browse files
authored
ref(allocator): Try to use jemalloc for etl-api and etl-replicator (#487)
1 parent 9aa0129 commit 447557b

File tree

6 files changed

+392
-5
lines changed

6 files changed

+392
-5
lines changed

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ serde_json = { version = "1.0.141", default-features = false }
7171
serde_yaml = { version = "0.9.34", default-features = false }
7272
sqlx = { version = "0.8.6", default-features = false }
7373
tempfile = { version = "3.23.0", default-features = false }
74-
thiserror = "2.0.12"
74+
thiserror = "2.0.12"
75+
tikv-jemalloc-ctl = { version = "0.6.0", default-features = false, features = ["stats"] }
76+
tikv-jemallocator = { version = "0.6.1", default-features = false, features = ["background_threads_runtime_support", "unprefixed_malloc_on_supported_platforms"] }
7577
tokio = { version = "1.47.0", default-features = false }
7678
tokio-postgres = { git = "https://github.com/MaterializeInc/rust-postgres", default-features = false, rev = "c4b473b478b3adfbf8667d2fbe895d8423f1290b" }
7779
tokio-rustls = { version = "0.26.2", default-features = false }

etl-api/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ RUN apt-get update && \
2020
pkg-config \
2121
libssl-dev \
2222
clang \
23-
lld && \
23+
lld \
24+
make && \
2425
rm -rf /var/lib/apt/lists/*
2526

2627
# Copy cargo config for build optimizations (lld linker, etc.)

etl-replicator/Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ etl-telemetry = { workspace = true }
1515

1616
anyhow = { workspace = true, features = ["std"] }
1717
configcat = { workspace = true }
18+
metrics = { workspace = true }
1819
reqwest = { workspace = true, features = ["rustls-tls", "json"] }
1920
secrecy = { workspace = true }
2021
sentry = { workspace = true }
@@ -28,3 +29,7 @@ sqlx = { workspace = true, features = [
2829

2930
tokio = { workspace = true, features = ["rt-multi-thread", "macros", "signal"] }
3031
tracing = { workspace = true, default-features = true }
32+
33+
[target.'cfg(not(target_env = "msvc"))'.dependencies]
34+
tikv-jemalloc-ctl = { workspace = true }
35+
tikv-jemallocator = { workspace = true }

etl-replicator/Dockerfile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@ ARG BUILDPLATFORM
1515
RUN echo "Native build on $BUILDPLATFORM for $TARGETPLATFORM"
1616

1717
# Install build dependencies including lld linker for faster linking
18-
# TODO: remove protobuf-compiler once the upstream gcp-bigquery-client remove it from its deps
18+
# TODO: remove protobuf-compiler once the upstream gcp-bigquery-client removes it from its deps.
1919
RUN apt-get update && \
2020
apt-get install -y \
2121
pkg-config \
2222
libssl-dev \
2323
protobuf-compiler \
2424
clang \
25-
lld && \
25+
lld \
26+
make && \
2627
rm -rf /var/lib/apt/lists/*
2728

2829
# Copy cargo config for build optimizations (lld linker, etc.)
@@ -44,6 +45,10 @@ WORKDIR /app
4445
# Create non-root user (distroless already has nonroot user)
4546
USER nonroot:nonroot
4647

48+
# jemalloc configuration is compiled into the binary (see main.rs).
49+
# Use MALLOC_CONF env var to override at runtime if needed.
50+
# Example: MALLOC_CONF="narenas:4,dirty_decay_ms:5000"
51+
4752
# Copy binary; configuration must be provided at runtime via mounted volume or environment overrides
4853
COPY --from=builder /app/target/release/etl-replicator ./etl-replicator
4954

0 commit comments

Comments
 (0)