Skip to main content

Module environment

Module environment 

Source
Expand description

§Environment variables

Every environment variable that latexml-oxide reads or sets, with the values it accepts, its default and its effect. A command-line flag always wins over the variable of the same meaning. Most variables are read once, when a conversion starts.

Audience legend

MarkWho it is for
useranyone running latexml_oxide from the command line
libraryRust code embedding the latexml crate
packagerbuilding, packaging or releasing the binaries
fleetcortex_worker deployments
devdiagnosing or measuring the converter; output and speed may change
testthe test suite only
internalset by latexml-oxide for its own child processes; never set these yourself

How values are read. Conventions differ between variables, so each row gives its own:

  • presence: the variable being set at all switches the feature on, whatever its value. LATEXML_NODUMP=0 also skips the dumps.
  • 1: only the exact value 1 switches it on.
  • 1|true|yes: one of those three values, case-sensitive.
  • 0 disables: the feature is on unless the value is exactly 0.
  • A number that does not parse falls back to the default, except LATEXML_MAX_MEMORY, which is a command-line error.

§Running conversions (user)

§Memory and limits

VariableValuesDefaultEffect
LATEXML_MAX_MEMORYMiB; 0 = no ceiling90 % of available RAM, at most 64 GiB, at least 2048 MiBlatexml_oxide only (not cortex_worker). The one memory knob of latexml_oxide, the same as --max-memory. The watchdog stops the run above it; the cooperative fuse sits at 3/4 of it; streaming spills at a third of the fuse.
LATEXML_STREAMINGtrue / falseunset = automaticlatexml_oxide only (not cortex_worker). The same as --streaming. true streams from the start; false never streams. 1 is rejected.
LATEXML_TOKEN_LIMITtokens; 0 disables20,000,000,000, raised to 1000 × the source sizeRunaway-expansion backstop (a Fatal). --token-limit wins. Setting either at all turns off the scaling with source size.
LATEXML_EXPAND_DEPTH_LIMITinteger; 0 disables12,000Nested expansion depth before Fatal:Timeout:Recursion.
LATEXML_MAX_GRAMMAR_LEXEMESinteger; 0 or none disables12,000Formulas longer than this skip the grammar parser for the simpler fallback parser.

Under an address-space limit (ulimit -v, as some batch systems impose), the allocators’ reservations count against the limit even though they use no memory. Two variables of the allocators themselves, not ours, cut that reservation by about half without changing memory use, speed or output:

VariableRecommendedEffect
MALLOC_ARENA_MAX2glibc: two malloc arenas instead of one per thread (each reserves 64-128 MiB).
MIMALLOC_ARENA_RESERVE128MiBmimalloc: reserve 128 MiB at a time instead of 1 GiB.

Without an address-space limit neither is needed. The fleet sets both for its children (see below).

§Format dumps

VariableValuesDefaultEffect
LATEXML_FORMAT_CACHEdirectory$XDG_CACHE_HOME/latexml-oxide/formats, else ~/.cache/latexml-oxide/formats, else latexml-oxide-formats-<uid> in the temp directoryWhere the format built for your TeX tree is cached. It is built once, on the first conversion with a tree the release’s embedded dumps were not built from, and kept per binary build (by its content: a copy shares it) and tree; the sets of other builds and trees unused for 30 days are pruned, except the three last used.
LATEXML_DUMP_DIRdirectoryunsetAlso look here for plain.YYYY.dump.txt / latex.YYYY.dump.txt.
LATEXML_DUMP_PATHfileunsetAn explicit LaTeX dump, used when it matches this TeX tree.
LATEXML_PLAIN_DUMP_PATHfileunsetAn explicit plain TeX dump.
LATEXML_NODUMPpresenceunsetLoad no dump; build the formats from the engine’s definitions on every run (slow).
LATEXML_SKIP_DUMP_STAMP_CHECKpresenceunsetSilence the TeX Live year-mismatch warning for the LaTeX dump.

§Post-processing, split and render

VariableValuesDefaultEffect
LATEXML_RENDER_JOBSinteger ≥ 1latexml_oxide: min(cores, 8); the library and cortex_worker: 1Worker processes that render the pages of a split run with 64 or more pages. 1 renders serially.
LATEXML_POST_STREAM_SPLIT0 = off, any other value = forced onautomatic for --splitat runsThe streaming split, which splits from the core result on disk instead of one whole document in memory.

§Graphics

VariableValuesDefaultEffect
LATEXML_GRAPHICS_CACHE_DIRdirectory; empty is ignored$XDG_CACHE_HOME/latexml-oxide/graphics, else $HOME/.cache/…; neither set = no cacheThe shared cache of converted images.
LATEXML_GRAPHICS_CACHE_OFF1|true|yescache onConvert every image afresh.
LATEXML_GRAPHICS_CACHE_MAX_MBMiB; 0 = never prune2048The cache’s size; the least recently used entries go first.
LATEXML_GRAPHICS_VECTOR_AUTO_OFF1|true|yesonTurn off the automatic PDF-to-SVG conversion of small vector figures (see --graphics-svg-threshold-kb).
LATEXML_RASTER_DENSITYdpi, 50-600120 (the longest side capped at 2048 px)Resolution of rasterized figures.
LATEXML_CONVERT_TIMEOUT_SECSseconds > 060Time limit for one ImageMagick or Ghostscript conversion.
LATEXML_SVG_CONVERT_TIMEOUT_SECSseconds > 015Time limit for one mutool or pdftocairo SVG conversion.

§Output, logging and safety

VariableValuesDefaultEffect
LATEXML_TELEMETRY_OUTfilenonelatexml_oxide only. Append one JSON line of timings and counts per conversion; the same as --telemetry-out. The record’s host is HOSTNAME, else /etc/hostname.
LATEXML_SOURCE_MAPpresenceofflatexml_oxide only. The same as --source-map: data-sourcepos attributes in the output.
LATEXML_DISABLE_SHELL_ESCAPEpresenceallowedRhai bindings may not run external commands (builds with runtime bindings). cortex_worker loads no runtime binding at all, so it needs no such setting.
SOURCE_DATE_EPOCHUnix secondsthe clockFixes \today, \time and the log banner’s time (UTC), and the member times of a .zip destination (--whatsout=archive) and of EPUB output, for reproducible builds.
NO_COLORpresencecolour on a terminalNo colour codes on stderr.
TMPDIR (TMP/TEMP on Windows)directorythe system defaultScratch files and temporary caches.

§TeX Live

latexml-oxide finds packages, classes and fonts through kpathsea, so the usual TeX Live variables apply: TEXMFROOT, TEXMFDIST, TEXMFMAIN, TEXMFLOCAL, TEXMFHOME, TEXMFVAR, TEXMFCONFIG, TEXMFSYSVAR, TEXMFSYSCONFIG, TEXMFCNF, TEXINPUTS, BIBINPUTS and the other *INPUTS paths. A trailing / on a tree root is trimmed and logged. KPSEWHICH names the kpsewhich program that anchors kpathsea; PATH also finds the external tools (kpsewhich, ImageMagick, Ghostscript, mutool, pdftocairo, texlua).

§Embedding the library (library)

VariableValuesDefaultEffect
LATEXML_RSS_CAP_BYTESbytes; 0 = off4,500,000,000The cooperative memory fuse (a graceful Fatal). The latexml_oxide binary sets its own from --max-memory, cortex_worker from --max-rss-mb; both ignore this.
LATEXML_NO_DEFAULT_PUSHBACK_LIMITpresencea 5,000,000-token capRemove the pushback cap.
LATEXML_STACK_RED_ZONE_BYTESbytes262,144Remaining stack below which a new stack segment is allocated.
LATEXML_STACK_SEGMENT_BYTESbytes8,388,608The size of each new stack segment.

§Building and packaging (packager)

VariableValuesDefaultEffect
LATEXML_GIT_SHAstringgit rev-parse --short HEAD, else unknownThe revision printed by --version and the log banner.
LATEXML_GIT_SHA_OVERRIDEstringthe git short shaThe revision recorded in telemetry.
LATEXML_NO_EMBEDDED_DUMPpresenceunsetRun time: do not fall back to the dumps compiled into the binary.
LATEXML_DUMP_DIR_ONLYpresenceunsetRun time: use only the dumps named by LATEXML_DUMP_PATH / LATEXML_DUMP_DIR or built for the tree.
KPATHSEA_SKIP_TOOLCHAIN_CHECK1set in .cargo/config.tomlBuild without a TeX installation.
PKG_CONFIG_PATH, LIBCLANG_PATH, VCPKG_ROOT, KPATHSEA_LIB_DIR, KPATHSEA_STATIC, LIBXML2_STATIC, LIBXSLT_STATICNative library discovery and static linking; see BUILDING.md.

tools/make_formats.sh (and .ps1) reads PROFILE (the cargo profile, default debug), CARGO_TARGET_DIR, CARGO_LOCKED=1 (build --locked) and LATEXML_DUMP_DIR (copy the built dumps there). tools/make_release.sh reads GITHUB_REF_NAME, RELEASE_TARGET, RELEASE_EXTRA_FEATURES and RELEASE_LOCKED. The other tools/ scripts document their variables in their headers.

§The cortex worker fleet (fleet)

cortex_worker is configured by its command-line options. For each child process it starts it sets:

VariableValueWhy
TMPDIR, MAGICK_TEMPORARY_PATH, MAGICK_TMPDIRa fresh directory per worker slotScratch space emptied between spawns.
MALLOC_ARENA_MAX, MIMALLOC_ARENA_RESERVE2, 128MiBThe children run under an address-space limit (--child-mem-limit-mb); see “Under an address-space limit”.
MALLOC_CONF, _RJEM_MALLOC_CONFbackground_thread:true,dirty_decay_ms:500,muzzy_decay_ms:0Prompt return of freed memory in jemalloc builds.
LATEXML_RSS_CAP_BYTES--child-mem-limit-mb − 256 MiB, else (--child-mem-limit-mb=0) --max-rss-mbThe per-child memory fuse: the child’s --max-rss-mb, which its conversions set it from.

These replace any value of the same name in the worker’s own environment. The worker loads no runtime .rhai binding in any build, nor do the children it spawns (each re-executes its main). The worker itself reads:

VariableValuesDefaultEffect
CORTEX_WORKER_THROTTLE_SECSseconds60How long an idle worker sleeps before asking the dispatcher for work again.
CORTEX_WORKER_IO_TIMEOUT_SECSseconds > 0120How long a worker waits on a dead or wedged dispatcher before giving up that exchange.
CORTEX_HARNESS_RAM_HEADROOM_PCTpercent, 10-10085pericortex’s worker-count clamp to RAM; cortex_worker never calls it, so it has no effect there (--workers and the memory governor size the fleet).

The Docker entrypoint reads WORKERS and PROFILE (ar5iv or generic).

§Diagnosing and measuring (dev)

These switch on traces, audits or alternative code paths. They are for developers; output and speed may change.

VariableValuesEffect
LATEXML_DEBUG_FATALpresenceA backtrace, the pushback and the last tokens at the first Fatal.
LATEXML_DEBUG_MEMBUDGETpresenceA backtrace and box statistics when the memory fuse trips.
LATEXML_CSNAME_TRACE, LATEXML_EXPL_TRACE, LATEXML_PGFKEYS_TRACE, LATEXML_CMML_TRACE_CYCLEpresenceTraces of \csname errors, expl3 syntax state at file exit, pgfkeys dispatch, Content MathML cycles.
LXML_TRACE_BOUND_MODE, LXML_TRACE_FRAMES, LXML_TRACE_TERMINAL, LXML_TRACE_GROUP_END, LXML_TRACE_ALIGN_STATE, LXML_SIZE_TRACE, LXML_TRACE_NODE_BOXES, LXML_TRACE_FRAGMENT_RC, LXML_TRACE_INSERT_BLOCKpresenceEngine traces: modes, frames, group ends, alignments, box sizes, streaming spills, fragment references, block insertion.
LXML_TRACE_ARGSa control sequence namePrint the arguments that definition reads.
LATEXML_REWRITE_TIMING, LATEXML_POST_AUDIT, LATEXML_POST_MEMDIAGpresenceTimings of rewrite rules and post-processing stages; heap statistics every 1024 pages (Linux).
LATEXML_PARSE_LEXEMES, LATEXML_PARSE_AUDIT, LATEXML_PARSE_PRUNE_REASONS, LATEXML_MATH_AMBIGUITY_AUDIT, LATEXML_MARPA_HYBRID_AUDIT_PARITY, LATEXML_MARPA_ASF_AUDIT, LATEXML_PARSE_DUMP_ORDERpresenceMath parser audits and dumps.
LATEXML_MARPA_LEGACY, LATEXML_MARPA_ASF_ONLYpresenceForce one math parse strategy (tree iteration or ASF).
LATEXML_MARPA_HYBRID_AND_NODE_LIMITinteger; 0/none = no cap (500)Bocage size above which the parser falls back to tree iteration.
LATEXML_L3FP_NATIVE, LATEXML_PGFKEYS_NATIVE, LATEXML_DATATOOL_NATIVE, LATEXML_CREF_NATIVE0 disablesTurn a native fast path off, to compare with the macro path.
LATEXML_L3FP_TRACE, LATEXML_L3FP_CHECK1Count the native l3fp calls; check them against the macro results.
LATEXML_NO_KPATHSEA_PREWARMpresenceSkip the kpathsea prewarm thread.
LATEXML_SPILL_AT_MIB, LATEXML_SEGMENT_CHUNK_MIB, LATEXML_SOFT_YIELD_MIN_BOXES, LXML_NODE_BOXES_SWEEPintegersStreaming watermark, segment size and yield points.
LATEXML_CHECK_READ_BUDGET, LATEXML_REHEARSAL_READ_BUDGETtokens; 0 = unlimitedBudgets of the frontmatter’s speculative reads (8,000,000).
LATEXML_POST_STREAM_THRESHOLD, LATEXML_POST_MEM_PARSE_LIMIT, LATEXML_POST_SPILL_PAGEbytes / 1Streaming-split threshold, in-memory parse ceiling, staging an unsplit page on disk.
LATEXML_INIT_DEBUGpresenceKeep and count the errors of an --init format build.
LATEXML_DUMPfileLoad an extra dump after the preloads.

§Tests (test)

LATEXML_BLESS, LATEXML_SAVE_ACTUAL, LATEXML_TEST_LOG, LATEXML_SIGSEGV_TRACE, LATEXML_TEST_TEXLIVE, LATEXML_TEST_SKIP_LOG, LATEXML_SVG_TESTS, LATEXML_BROWSER_TESTS, LATEXML_EPUBCHECK_TESTS, LATEXML_FIREFOX, LATEXML_BROWSER_ENGINE, LATEXML_FIREFOX_PATH, LATEXML_INJECT_PANIC, LATEXML_RENDER_TEST_SERIAL_STOP, LATEXML_RENDER_WORKER_TEST_ABORT, CORTEX_WORKER_TEST_FAULT, CORTEX_WORKER_TEST_GROW_MB, UPDATE_SUPPORTED_PACKAGES, UPDATE_API_DOC and LATEXML_PERL_LIB drive the test suite: blessing goldens, requiring optional tools (a missing mutool, browser or epubcheck becomes a failure instead of a skip), and fault injection. BUILDING.md describes the ones a contributor uses.

§Internal (do not set)

VariableSet byEffect if set by hand
LATEXML_INI_MODEnothing (latexml_oxide --init sets the same switch in process)A normal conversion stops after the bootstrap pools.
LATEXML_RENDER_WORKERthe render fleet, for its workerslatexml_oxide ignores its command line and waits as a render worker.