Performance Baseline
The performance targets tyc aims for. Numbers measured on a 2024 M-series Mac; expect similar on modern x86.
Compile-time performance
| Operation | Target | Notes |
|---|---|---|
tyc check (single file, cold) | < 50 ms | First invocation; populates Salsa cache. |
tyc check (single file, warm) | < 10 ms | Subsequent runs; cache hit. |
tyc check (100-file project, cold) | < 1.5 s | Linear in file count for cold builds. |
tyc check (100-file project, warm, single-file edit) | < 50 ms | Salsa invalidates only the changed file’s downstream. |
tyc build (100-file project, cold) | < 2 s | Adds emit + format. |
tyc fmt (single file) | < 5 ms | Lex + reprint. |
LSP performance
| Operation | Target | Notes |
|---|---|---|
Republish diagnostics on didChange | < 100 ms | Edit to first squiggle. |
| Hover | < 20 ms | After diagnostics have published. |
| Go-to-definition (in-file) | < 20 ms | Local lookup. |
| Go-to-definition (cross-file) | < 100 ms | Requires resolved_module query. |
| Completion | < 50 ms | Bindings + 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 defaultclassemission) 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 perOk(...)/Err(...). Microsecond-scale per call; meaningful only in tight loops.gather:adds a smallTaskGroupoverhead vs sequential awaits — pays off when each await is sub-millisecond.
See Performance Gotchas for the patterns to watch.
Build artefact size
| Artefact | Typical size |
|---|---|
typhon_runtime/result.py | ~30 lines |
typhon_runtime/tasks.py | ~10 lines |
typhon_runtime/lazy.py | ~25 lines |
.py.map per source file | 5–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 checklatency under 50ms cold, under 10ms warm. - LSP
didChangelatency 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-syntaxif 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
- Performance Gotchas — runtime patterns to watch.
- Salsa Queries — what the incremental layer caches.