Profiling rules
Set TIMING, exactly as with ESLint:
The table goes to stderr, so -f json output on stdout stays parseable
(ESLint prints it to stdout). Results are identical with and without it. The
CLI reference shows a full example.
The rule table
Rule, Time (ms) and Relative mean what they mean in ESLint: a rule's
time, including the type information it asked for, and its share of all rule
time. lintrs splits that time, so for every row
Time = Own + Adapter + Checker + Crossing + Node maps:
How to read it:
- High
Own: the rule's own logic is the cost. - High
Adapter: presenting tsrs results as TypeScript's API is the cost, not the rule or the checker. - High
Checker: real type-checking work; batching won't help much. - High
Crossing, manyCalls: a chatty rule. Fewer, larger requests would help. - High
Crossing, fewCalls: large results crossing the boundary.
The adapter
Typed JavaScript rules expect TypeScript's checker API: Type, Symbol and
Node objects with properties and methods. lintrs presents tsrs results that
way through a compatibility layer, and that layer's work is Adapter:
- reading properties of wrapped types, symbols, signatures and nodes
(
type.flags,signature.parameters, …); - wrapping SDK objects into those compatible objects;
- the checker methods' own work: unwrapping arguments, memoized answers, and building and wrapping results.
Checker requests made along the way still count as Checker and Crossing.
Callbacks a checker method hands back to the rule count as Own. ESLint has
no equivalent: typescript-eslint works on TypeScript's own objects there.
The adapter table after the phases breaks Adapter down by entry, so you can
see which part of the layer the time goes to:
Each entry's time includes adapter work nested under it (wrapping a method's
result counts toward the method), but never checker requests or rule
callbacks. A high Avg (µs) marks an entry that is expensive per call; a
high Calls with a low average marks one that is cheap but hot.
Rust rules
Rust rules are timed in Rust, per rule, across initialize
and every visit. They call the checker directly, so their checker work is
part of Own and Adapter, Checker, Crossing and Calls are 0.
Transports
The checker split needs the in-process binding, which the release layout
uses by default. On the child-process transport, Checker holds the whole
request and Crossing shows -.
The phase table
With --concurrency, rule and phase times are summed across worker threads,
so they can exceed the wall time.
Wall time starts before the host imports and ends after linting. It excludes Node process startup, the CLI's own static imports, and formatting/writing the final output. Configuration imports are included, so a cold run can show whether loading plugins costs more than executing their rules. Compare unprofiled runs separately when measuring a performance change.
JSON
LINTRS_TYPE_PROFILE=profile.json writes the same numbers under timing,
plus each rule's five most expensive checker methods (ms there is the
whole call, checker and crossing), next to the type-service totals:
Rules also carry topAdapterEntries, and timing.adapterEntries lists every
adapter entry across the run, costliest first:
timing.checkerMethods lists every checker method across the run, costliest
crossing first. With the in-process binding each method's crossing splits
further, into conversionMs (Node-API conversion of arguments and results,
in Rust) and jsSideMs (the call itself, JSON work and SDK wrapping in JS):
crossingMs is null on the child-process transport. With the in-process binding the file
also has binding.typedArgumentsMs and binding.typedResultsMs: the
conversion time spent decoding typed-query arguments and encoding their
results. Rust rules also carry
ruleCalls, the number of initialize and visit calls.
Cost
Profiling adds about 15% to a typed run while it is on, mostly from timing
every adapter entry (millions per run). That timing also adds slightly to the
Adapter figure itself, under 10% of it. When profiling is off, rules and
the adapter run unwrapped and Rust rules are not timed.
