DEV Community

Shota M. | Air-Gapped HPC Arch

Eliminating Exit 137 OOM Crashes in 10M Batch Workloads: 9 Docker Flags, libjemalloc2 Injection, and O(1) Polars Streaming


Executing 10,000,000 asynchronous LLM batch inferences or parsing 100GB+ binary files (ASPRS LAS, PCAPNG, ASAM MDF4, SEG-Y, BAM) on standard Linux containers routinely terminates with an Exit 137 (SIGKILL) Out-Of-Memory crash. Even on cloud instances provisioned with 128GB to 512GB of RAM, memory consumption climbs monotonically until the Linux kernel OOM killer terminates the process.

Across two consecutive full production runs on a single bare-metal workstation (HP Z4 G4, Intel Xeon W-2155, 128GB DDR4-2666 ECC RDIMM, NVIDIA RTX 5060 Ti 16GB clamped at 160W, 2TB PCIe Gen4 NVMe raw partition /mnt/data), we executed 10,000,000 batch inference records in 10.9 hours (39,240 seconds) at an average throughput of 254.9 req/s with a 0.00% error rate (10,000,000 / 10,000,000 succeeded) and $0.00 cloud compute cost.

Throughout the entire 10.9-hour execution window, host RAM remained strictly bounded between 6.7GiB and 9.4GiB (O(1) constant space) with 0 bytes of swap usage.

9 Docker Run Parameters

1. Root Cause of the OOM Cliff: Glibc Arena Retention and In-Memory Accumulation

Two architectural flaws cause memory exhaustion in high-throughput Python/C++ data pipelines:

  1. Glibc ptmalloc Heap Fragmentation: Standard Linux containers use glibc as the default allocator. Under multi-threaded asynchronous workloads (asyncio, vLLM, PyTorch, Polars), glibc creates per-thread memory arenas to reduce lock contention. When small objects remain allocated near the top of a heap chunk, free() does not return the underlying physical pages to the OS kernel via brk or madvise. Resident Set Size (RSS) ratchets upward indefinitely.
  2. Unbounded In-Memory Frame Accumulation: Calling .append() on Python lists or materializing full DataFrames prior to disk write creates an O(N) memory spike that exceeds physical RAM capacity.

2. The 9 Deterministic Docker Run Parameters

To enforce an O(1) memory boundary and eliminate socket exhaustion (ZMQError / HTTP 500), the container runtime must be locked at startup:

docker run -d --name airgapped-hpc-engine \
  --gpus all \
  --memory="90g" --memory-swap="90g" \
  --ipc=host \
  --ulimit nofile=1048576:1048576 \
  --tmpfs /tmp:rw,exec,nosuid,size=20g \
  -v /usr/lib/wsl/lib:/usr/lib/wsl/lib:ro \
  -v /mnt/data:/mnt/data:rw \
  -e LD_PRELOAD="/usr/lib/x86_64-linux-gnu/libjemalloc.so.2:/usr/lib/wsl/lib/libcuda.so.1" \
  -e MALLOC_CONF="background_thread:true,dirty_decay_ms:2000,muzzy_decay_ms:2000" \
  -e ZMQ_MAX_SOCKETS=65535 -e MAX_ZMQ_SOCKETS=65535 \
  -e HF_HOME=/tmp/hf_cache -e OUTLINES_CACHE_DIR=/tmp/outlines \
  -e XDG_CACHE_HOME=/tmp/cache -e XDG_CONFIG_HOME=/tmp/config \
  --network none \
  hpc-baseline:production-jemalloc
Enter fullscreen mode Exit fullscreen mode

Critical Flag Breakdown:

  • LD_PRELOAD & MALLOC_CONF: Overrides glibc with libjemalloc2. Setting background_thread:true,dirty_decay_ms:2000,muzzy_decay_ms:2000 forces dedicated background threads to issue MADV_DONTNEED syscalls every 2,000ms, immediately returning unused dirty pages to the Linux kernel.

  • --memory="90g" --memory-swap="90g": Enforces a hard cgroup ceiling with zero swap tolerance, preventing disk thrashing.

  • --tmpfs /tmp:rw,exec,nosuid,size=20g: Isolates ephemeral caches in RAM, protecting physical NVMe endurance.

  • --network none: Physically severs all external network interfaces at the kernel namespace level, guaranteeing zero data egress and zero cloud API billing.

3. Out-of-Core Streaming and Two-Phase Atomic Persistence

To maintain a flat 6.7GiB-9.4GiB memory footprint while writing multi-gigabyte outputs, all transformations stream directly to a raw ext4 NVMe partition (/mnt/data) bypassing virtual disk abstraction layers:

Polars Out-of-Core Sink: Data streams through collect(engine="streaming") and sink_parquet() with row_group_size=100_000. Output writes first to a staging file (.parquet.tmp) and promotes via atomic os.replace() only after verification.

SQLite WAL Kill-9 Immunity: State tracking uses SQLite in WAL mode (PRAGMA journal_mode=WAL; PRAGMA synchronous=NORMAL;) with BEGIN IMMEDIATE batch commits every 50,000 to 100,000 records and a background coroutine executing PRAGMA wal_checkpoint(TRUNCATE); every 10 minutes. Across unannounced kill -9 (SIGKILL) tests on our 3.4GB state database, recovery completed with zero data loss (PRAGMA integrity_check: ok).

4. Production Air-Gapped Container Engines & Free 1-File PoV

We do not host or process client production data on third-party clouds. We deliver reproducible, air-gapped Docker IaC containers directly to your on-premises or private VPC boundary.

Direct Commercial Downloads (Polar.sh Instant Checkout):

  1. Air-Gapped HPC Base IaC Bundle ($1,200.00 USD)
    SHA-256: 1CB70C60C14C83CDD0AE799567D5CAFCF0E103B36CA7A3C29C775837689BB2FB
    Checkout: https://buy.polar.sh/polar_cl_VUZ9enyIdPvLsFRr3wSMIfDFkIGVNwTo0ZskH3fRZfv

  2. GeoStream-Parquet Engine v1.0.0 - ASPRS LAS/LAZ ($1,800.00 USD)
    SHA-256: 281e07482d51dd4a195726c845deb6584f247e77e045c5bee11d187ae4ee0c0d
    Checkout: https://buy.polar.sh/polar_cl_Xzj1yyC6t5Xh6iDy1cf7odEVmOBPxClhSnrvI1Z68Bj

  3. NetForensic-Core v1.0.0 - PCAP/PCAPNG ($1,800.00 USD)
    SHA-256: 5203e2885b9d87e8dbd68cbcc01425c6351d8ff03caee9beeb77ae7657b3ab54
    Checkout: https://buy.polar.sh/polar_cl_PDU5vVPDdyrQuXBwGdLm6mM2XfB10TTxvA7ze3aMeS3

  4. MDF4-Parquet Engine v1.0.0 - Automotive ASAM MDF4 ($2,500.00 USD)
    SHA-256: cb1b15827908a94d2bc06fcde823e8c8feb4be2b3cac4d891d3dc8aa969b551a
    Checkout: https://buy.polar.sh/polar_cl_Pp43kjfUkophrVuuXx8jaS0IFh1RBWgbtlFXq0Eei7D

  5. SeisParquet-Core v1.0.0 - Geophysical SEG-Y ($2,800.00 USD)
    SHA-256: 0441bb4ff617b76ee55992e5bf0d6dc816bff8fbc2337e52b3968487c03d1f48
    Checkout: https://buy.polar.sh/polar_cl_H0B1ZerOs1jAcivd2vOBlfXmQMqnITRZEftAV21BxIK

  6. BioBAM-Streamer v1.0.0 - Genomic BAM/CRAM ($3,000.00 USD)
    SHA-256: ef7a29f12ec6cad14c9824a1526c80e93d46542841390a4f375f74bed68b547c
    Checkout: https://buy.polar.sh/polar_cl_kjbvee0H5zG4ahd3MlgTvRStIDMkHQU52GpEy0BIEdF

Request a Free 1-File Test Conversion (Proof-of-Value):
Unsure if your 10GB-100GB+ binary dataset will trigger OOM crashes? Send 1 non-PHI sample file to shota@shotamatsubara.com for a zero-cost 10-minute test run under --network none. You will receive complete memory profile logs proving 0.00% error rate and locked RAM ceilings prior to purchase. Sample files are shredded immediately after verification.

Official Architecture LP & Video Vault: https://shotamatsubara.com

GitHub Benchmark Hub: https://github.com/Matsubara-CEO

Upwork Fixed-Price Contracts ($1,000-$5,000 USD): https://www.upwork.com/freelancers/shotamatsubara

Terms: All software and IaC deliverables are provided strictly "AS IS" without warranty of any kind under UCC Section 2-316. Total liability is strictly capped at the purchase price paid.

Top comments (0)