Skip to content

Performance Baseline

The performance targets tyc aims for. Numbers measured on a 2024 M-series Mac; expect similar on modern x86.

Compile-time performance

OperationTargetNotes
tyc check (single file, cold)< 50 msFirst invocation; populates Salsa cache.
tyc check (single file, warm)< 10 msSubsequent runs; cache hit.
tyc check (100-file project, cold)< 1.5 sLinear in file count for cold builds.
tyc check (100-file project, warm, single-file edit)< 50 msSalsa invalidates only the changed file’s downstream.
tyc build (100-file project, cold)< 2 sAdds emit + format.
tyc fmt (single file)< 5 msLex + reprint.

LSP performance

OperationTargetNotes
Republish diagnostics on didChange< 100 msEdit to first squiggle.
Hover< 20 msAfter diagnostics have published.
Go-to-definition (in-file)< 20 msLocal lookup.
Go-to-definition (cross-file)< 100 msRequires resolved_module query.
Completion< 50 msBindings + keywords + builtins.

Runtime performance of emitted Python

The emitted Python runs exactly as fast as the same hand-written Python. Typhon does not change runtime characteristics. Three observations:

  • @dataclass(slots=True) (the default class emission) is roughly ~30% more memory-efficient than a plain class with __dict__, with negligible attribute-access overhead on 3.11+.
  • Result[T, E] allocates a small dataclass per Ok(...) / Err(...). Microsecond-scale per call; meaningful only in tight loops.
  • gather: adds a small TaskGroup overhead vs sequential awaits — pays off when each await is sub-millisecond.

See Performance Gotchas for the patterns to watch.

Build artefact size

ArtefactTypical size
typhon_runtime/result.py~30 lines
typhon_runtime/tasks.py~10 lines
typhon_runtime/lazy.py~25 lines
.py.map per source file5–20% of the .py size

The generated typhon_runtime/ ships with your wheel. No PyPI dependency.

CI performance

tyc check runs in seconds on a CI runner — comparable to ruff check for the same project. The most expensive CI gate is typically the actual test run, not tyc check.

What we will not regress

  • Single-file tyc check latency under 50ms cold, under 10ms warm.
  • LSP didChange latency under 100ms.
  • No runtime overhead from Typhon-specific lowering vs hand-written equivalent.

Regressions are tracked in the bench corpus (TBD as the project matures).

What we may optimise

  • Salsa durability tuning for stdlib queries.
  • Arena allocation in tyc-syntax if AST size starts dominating.
  • Parallel typechecking across files (Salsa supports it; we’d need to verify thread-safety).
  • Streaming Python emission for very large projects.

None of these are urgent.

Where next