orthonym.runtime_tuning#
Note
Internal API. Names and behaviour may change between releases.
Process-level tuning for batch naming workers (perf lever A1 + A11, 2026-09-13).
Two knobs, both invisible to the names and tiers the engine emits:
Python cyclic GC. Naming allocates millions of small objects per molecule (RDKit wrappers, tuples, dicts). With the default thresholds
(700, 10, 10)the collector runs every ~700 net allocations and rescans the long-lived module data each time it reaches generation 2. Measured on 100 fixed-seed molecules, one core, twice each (2026-09-12): default 36.3 s;gc.freeze+ threshold(50_000, 20, 20)31.8 s (-12 %); freeze +gc.disable30.1 s (-17 %). Names identical in every mode. RSS grew LESS with the collector frozen (+42 MB vs +185 MB over 150 molecules), because the growth is lexicon warm-up, not garbage. The collector stays ON here (high threshold) so a 16,000-molecule shard cannot accumulate cyclic garbage unbounded.BLAS/OpenMP thread pools. numpy’s bundled OpenBLAS spawns one thread per CPU (59 idle threads per worker on this 60-vCPU host, 2,400 across a 41-worker run). They use no CPU but cost memory and scheduler noise; one thread is the right size for a process that never calls BLAS in parallel.
Opt-in. The repo’s batch runners (eval/harness.py, scripts/perf/name_sample.py) call
tune_batch_process() explicitly; any other runner sets ORTHONYM_GC_TUNE=on and
the first Orthonym constructed in the process applies it via
maybe_tune_from_env(). ORTHONYM_GC_TUNE=off disables both paths (A/B runs).
A library user who imports orthonym and never sets the variable is untouched.
- orthonym.runtime_tuning.tune_batch_process(threshold=(50000, 20, 20), *, freeze=True, blas_threads=1)#
Apply the batch-worker tuning once per process. Returns True if applied (now or earlier), False if
ORTHONYM_GC_TUNE=off. Idempotent; safe to call per molecule.
- orthonym.runtime_tuning.maybe_tune_from_env()#
Apply:func:tune_batch_process iff
ORTHONYM_GC_TUNEison/1/true.
- orthonym.runtime_tuning.is_tuned()#