Benchmarks¶
Apple M1 Pro (macOS arm64), CPython 3.15.2, release build (maturin build --release), vs textfsm 2.1.1 from PyPI. ntc-templates workloads use ntc-templates 9.4.0 (06fa3338, 2026-11-19).
| Workload | textfsm 2.1.1 | textfsm2 | Speedup | Time saved |
|---|---|---|---|---|
cisco_ios show interfaces: construct + ParseText | 1.65 ms | 0.23 ms | 7.3× | 86.3% |
brocade show interfaces (3.2k lines): ParseText | 34.6 ms | 3.39 ms | 10.2× | 90.2% |
nxos show ip bgp neighbors (3.5k lines): ParseText | 17.0 ms | 1.69 ms | 10.0× | 90.0% |
nxos show ip bgp neighbors (3.5k lines): ParseTextToDicts | 17.4 ms | 1.77 ms | 9.8× | 89.8% |
| 32 × nxos bgp parses on 4 threads | 558.6 ms | 16.7 ms | 33.4× | 97.0% |
ntc-templates parse_output (1,906 files, cold cache) | 6.48 s | 688.5 ms | 9.4× | 89.4% |
ntc-templates parse_output (1,906 files, warm cache) | 6.57 s | 352.9 ms | 18.6× | 94.6% |
| Overall (geometric mean across 7 workloads) | — | — | 12.3× | 91.9% |
A short-lived process that compiles one template, parses one output, and exits takes 53.4 ms against textfsm's 51.9 ms (peak RSS 24.9 MB vs 22.9 MB) (scripts/bench/compare.sh -w oneshot), because each regex is validated by CPython and compiled in Rust.
Resource usage¶
Speed is half the goal: in ETL pipelines that parse device output at scale, CPU time and memory decide how many workers fit on a host. These tables compare both with textfsm, and with free-threaded Python.
Peak memory (RSS) of each benchmark process, from interpreter start to exit, and CPU time (all threads, user + system) per run. Same machine and builds as above; ntc-templates 9.4.0 (06fa3338, 2026-11-19). Lower is better.
| Peak memory | textfsm 2.1.1 | textfsm2 3.15 | Change | textfsm2 3.15t |
|---|---|---|---|---|
| Parsing workloads 1–5 (one process) | 36 MB | 35 MB | -2% | 47 MB |
ntc-templates parse_output (1,906 files, cold cache) | 49 MB | 96 MB | +96% | 105 MB |
ntc-templates parse_output (1,906 files, warm cache) | 49 MB | 258 MB | +423% | 267 MB |
ntc-templates parse_output (1,906 files, warm cache, 4 threads) | 53 MB | 266 MB | +403% | 302 MB |
| CPU time | textfsm 2.1.1 | textfsm2 3.15 | Change | textfsm2 3.15t |
|---|---|---|---|---|
cisco_ios show interfaces: construct + ParseText | 1.65 ms | 0.23 ms | -86% | 0.23 ms |
brocade show interfaces (3.2k lines): ParseText | 34.6 ms | 3.39 ms | -90% | 3.37 ms |
nxos show ip bgp neighbors (3.5k lines): ParseText | 17.0 ms | 1.69 ms | -90% | 1.71 ms |
nxos show ip bgp neighbors (3.5k lines): ParseTextToDicts | 17.4 ms | 1.77 ms | -90% | 1.77 ms |
| 32 × nxos bgp parses on 4 threads | 559.7 ms | 63.2 ms | -89% | 64.1 ms |
ntc-templates parse_output (1,906 files, cold cache) | 6.48 s | 688.5 ms | -89% | 722.4 ms |
ntc-templates parse_output (1,906 files, warm cache) | 6.56 s | 352.9 ms | -95% | 379.6 ms |
ntc-templates parse_output (1,906 files, warm cache, 4 threads) | 6.69 s | 473.1 ms | -93% | 466.4 ms |
The warm-cache rows keep up to 2,048 compiled templates in memory (TEXTFSM_CACHE_SIZE=2048); that cache is where most of the extra memory goes. See the notes below for trading memory against speed.
Free-threaded Python¶
TextFSM2 supports free-threaded CPython: the extension never re-enables the GIL, and threads give the same results as a sequential run. On a free-threaded build, the Python half of each parse (ntc-templates, CliTable, the record handling in parser.py) runs in parallel too, so multi-threaded parsing scales with cores instead of queueing on the GIL.
TextFSM2 on free-threaded CPython 3.15.2 (3.15t) against standard CPython 3.15.2: same machine, same sources, release builds, ntc-templates 9.4.0 (06fa3338, 2026-11-19). Goal: as fast as or faster on every workload (✓ within 5%; above 1× is faster).
| Workload | Standard 3.15 | Free-threaded 3.15t | 3.15t vs 3.15 |
|---|---|---|---|
cisco_ios show interfaces: construct + ParseText | 0.23 ms | 0.23 ms | 1.00× ✓ |
brocade show interfaces (3.2k lines): ParseText | 3.39 ms | 3.37 ms | 1.01× ✓ |
nxos show ip bgp neighbors (3.5k lines): ParseText | 1.69 ms | 1.71 ms | 0.99× ✓ |
nxos show ip bgp neighbors (3.5k lines): ParseTextToDicts | 1.77 ms | 1.77 ms | 1.00× ✓ |
| 32 × nxos bgp parses on 4 threads | 16.7 ms | 16.8 ms | 1.00× ✓ |
ntc-templates parse_output (1,906 files, cold cache) | 688.5 ms | 722.4 ms | 0.95× ✓ |
ntc-templates parse_output (1,906 files, warm cache) | 352.9 ms | 379.7 ms | 0.93× ✗ |
ntc-templates parse_output (1,906 files, warm cache, 4 threads) | 317.1 ms | 158.5 ms | 2.00× ✓ |
Notes¶
- Catastrophic backtracking: One template in
ntc-templates(cisco_s300_show_vlan) contains^(\s*-*)*\s*$, which makes CPython'srebacktrack exponentially (textfsmneeds 2.3 s for a 15-line input).textfsm2evaluates that rule with a linear-time automaton and produces the identical result, because the rule extracts no values. - Cold vs. warm cache:
ntc-templatescycles through roughly 1,000 distinct templates—more than the defaultTEXTFSM_CACHE_SIZE=128holds—so a cold run recompiles templates on every miss, while a warm run (TEXTFSM_CACHE_SIZE=2048) hits cached programs and pooled search caches. - Memory: A compiled template costs about 100 KB, plus about 130 KB of warm search caches once used. The default cache of 128 templates stays under about 30 MB. With
TEXTFSM_CACHE_SIZE=0, memory use matches upstreamtextfsmand parsing stays about 3× faster.
Reproducing locally¶
The published numbers are refreshed for every release by make release, on the machine named above. Pull requests get a separate comment comparing ntc-templates performance and coverage with their base branch.
Every benchmark builds a real --release wheel (maturin build --release) into an isolated environment under .bench/ (never the editable dev build):