Files
rustyip/Cargo.toml
T
NetworkCatsandClaude Opus 5.5 036a3fa061 Use mimalloc for request-path allocations
The production image is built against musl, whose allocator is slow and
takes a global lock. Profiling /json on a 1 CPU / 1 GB Alpine container
showed malloc/free at ~11% of total CPU, the largest user-space cost;
the rest is mostly the kernel network stack, already at one recvfrom
and one writev per request.

mimalloc alone, however, kept the freed ~96 MB MMDB buffer resident
after a database update (RSS stayed at ~197 MB in two of three swaps),
and MIMALLOC_PURGE_DELAY=0 fixes that only by giving back most of the
speedup. So blocks of 1 MiB or more, in practice only the MMDB file
contents, go to the system allocator, which unmaps them on free; RSS
returns to ~98 MB after every swap, as before.

Median of three alternating 20 s runs: /json across random IPs rose
from 131.6k to 142.4k rps (+8%), p50 latency 0.465ms -> 0.443ms; a
single IP rose from 124.5k to 127.4k rps (+2%). Steady-state RSS grows
by ~12 MB. Responses are byte-identical to before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 19:16:07 +08:00

39 lines
901 B
TOML

[package]
name = "rustyip"
version = "0.1.0"
edition = "2024"
[dependencies]
axum = "0.8.8"
tower = { version = "0.5", features = ["util"] }
tokio = { version = "1.49.0", features = ["rt-multi-thread", "macros", "net", "signal", "time", "fs", "io-util"] }
askama = "0.15.4"
maxminddb = "0.27.3"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
arc-swap = "1"
reqwest = { version = "0.13", default-features = false, features = ["rustls"] }
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
dotenvy = "0.15"
urlencoding = "2"
tokio-util = "0.7"
static-files = "0.3.1"
quick_cache = "0.7"
mimalloc = "0.1.52"
[build-dependencies]
static-files = "0.3.1"
[dev-dependencies]
http-body-util = "0.1"
tower = { version = "0.5", features = ["util"] }
tempfile = "3"
[profile.release]
opt-level = 3
lto = true
codegen-units = 1
strip = true
panic = "abort"