From 6114a00fb8ff7f88fc48cbcfc62c58a4de74cb19 Mon Sep 17 00:00:00 2001 From: Juergen Kunz Date: Tue, 24 Feb 2026 23:22:49 +0000 Subject: [PATCH] feat(rustproxy): use tikv-jemallocator as the global allocator to reduce glibc fragmentation and slow RSS growth; add allocator dependency and enable it in rustproxy, update lockfile, and run tsrust before tests --- changelog.md | 8 ++++++++ package.json | 2 +- rust/Cargo.lock | 21 +++++++++++++++++++++ rust/Cargo.toml | 3 +++ rust/crates/rustproxy/Cargo.toml | 1 + rust/crates/rustproxy/src/main.rs | 3 +++ ts/00_commitinfo_data.ts | 2 +- 7 files changed, 38 insertions(+), 2 deletions(-) diff --git a/changelog.md b/changelog.md index 93547e5..60b5975 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,13 @@ # Changelog +## 2026-02-24 - 25.8.0 - feat(rustproxy) +use tikv-jemallocator as the global allocator to reduce glibc fragmentation and slow RSS growth; add allocator dependency and enable it in rustproxy, update lockfile, and run tsrust before tests + +- Added tikv-jemallocator dependency to rust/Cargo.toml and rust/crates/rustproxy/Cargo.toml +- Enabled tikv_jemallocator as the global allocator in rust/crates/rustproxy/src/main.rs +- Updated rust/Cargo.lock with tikv-jemallocator and tikv-jemalloc-sys entries +- Modified package.json test script to run tsrust before tstest + ## 2026-02-24 - 25.7.10 - fix(rustproxy) Use cooperative cancellation for background tasks, prune stale caches and metric entries, and switch tests to dynamic port allocation to avoid port conflicts diff --git a/package.json b/package.json index 77e2104..696ec95 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "author": "Lossless GmbH", "license": "MIT", "scripts": { - "test": "(tstest test/**/test*.ts --verbose --timeout 60 --logfile)", + "test": "(tsrust) && (tstest test/**/test*.ts --verbose --timeout 60 --logfile)", "build": "(tsbuild tsfolders --allowimplicitany) && (tsrust)", "format": "(gitzone format)", "buildDocs": "tsdoc" diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 0ea3d3e..a9fe2f8 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -936,6 +936,7 @@ dependencies = [ "rustproxy-tls", "serde", "serde_json", + "tikv-jemallocator", "tokio", "tokio-rustls", "tokio-util", @@ -1298,6 +1299,26 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "tikv-jemalloc-sys" +version = "0.6.1+5.3.0-1-ge13ca993e8ccb9ba9847cc330696e02839f328f7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd8aa5b2ab86a2cefa406d889139c162cbb230092f7d1d7cbc1716405d852a3b" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "tikv-jemallocator" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0359b4327f954e0567e69fb191cf1436617748813819c94b8cd4a431422d053a" +dependencies = [ + "libc", + "tikv-jemalloc-sys", +] + [[package]] name = "time" version = "0.3.47" diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 84f45e9..54f4715 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -91,6 +91,9 @@ libc = "0.2" # Socket-level options (keepalive, etc.) socket2 = { version = "0.5", features = ["all"] } +# jemalloc allocator (prevents glibc fragmentation / slow RSS growth) +tikv-jemallocator = "0.6" + # Internal crates rustproxy-config = { path = "crates/rustproxy-config" } rustproxy-routing = { path = "crates/rustproxy-routing" } diff --git a/rust/crates/rustproxy/Cargo.toml b/rust/crates/rustproxy/Cargo.toml index 875ccd8..d3bb8c3 100644 --- a/rust/crates/rustproxy/Cargo.toml +++ b/rust/crates/rustproxy/Cargo.toml @@ -39,6 +39,7 @@ hyper = { workspace = true } hyper-util = { workspace = true } http-body-util = { workspace = true } bytes = { workspace = true } +tikv-jemallocator = { workspace = true } [dev-dependencies] rcgen = { workspace = true } diff --git a/rust/crates/rustproxy/src/main.rs b/rust/crates/rustproxy/src/main.rs index 0ebcc9a..d59778b 100644 --- a/rust/crates/rustproxy/src/main.rs +++ b/rust/crates/rustproxy/src/main.rs @@ -1,3 +1,6 @@ +#[global_allocator] +static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; + use clap::Parser; use tracing_subscriber::EnvFilter; use anyhow::Result; diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index 96fc869..8c8f318 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@push.rocks/smartproxy', - version: '25.7.10', + version: '25.8.0', description: 'A powerful proxy package with unified route-based configuration for high traffic management. Features include SSL/TLS support, flexible routing patterns, WebSocket handling, advanced security options, and automatic ACME certificate management.' }