Skip to content

Enhance/extend general & TypeForm-specific performance instrumentation - #21832

Open
davidfstr wants to merge 2 commits into
python:masterfrom
davidfstr:f/perfcompare_more_sensitive
Open

Enhance/extend general & TypeForm-specific performance instrumentation#21832
davidfstr wants to merge 2 commits into
python:masterfrom
davidfstr:f/perfcompare_more_sensitive

Conversation

@davidfstr

Copy link
Copy Markdown
Contributor

Contains 2 commits:

  • C1. misc/perf_compare.py: Add options/behaviors to reduce measured variance
    • Extends perf_compare.py to support more-precise measurements of mypy's performance
  • C2. TypeForm: Add instrumentation of full parses done in semanal.py's try_parse_as_type_expression()
    • Adds TypeForm-specific instrumentation of (expensive) full parses of expressions as type expressions in semanal.py's try_parse_as_type_expression().

See the individual commit messages for more details.

I'm planning to use these instrumentation enhancements 1-3 upcoming PRs aimed at reducing the slowdown that TypeForm recognition introduces when it is enabled. Related:

  • Original 7-filter PR that attempted to reduce slowdown all at once. Will be superceded by other PR(s).

davidfstrand others added 2 commits August 9, 2026 21:07
Specifically:
* Median is reported, in addition to the existing mean+stdev, which is
significantly more resistant to skew by outliers.
* --metric {wall,cpu} (default wall): Enables profiling using CPU time
rather than wall-clock time. CPU profiling has roughly half the coefficient
of variation as wall-clock profiling equal run count.
* --workers1: Forces MYPY_NUM_WORKERS=1 (rather than the default 4) to
cut CPU scheduling variance. Strongly recommended when using --metric cpu.
* --warmup-runs N (default 1): Configurable number of leading cold runs to discard.
Previously was always 1. Higher run counts decrease outliers that skew
the reported mean.
* A new "Paired deltas vs <first commit>" section is added to the report,
showing per-round paired differencing against the first commit
to cancel round-level common-mode noise, reducing variance.
Reported as median +/-95% CI.
Also:
* --cache-binaries (default false): Caches each commit's compiled clone
to avoid ~5min recompile whenever comparing the same commit multiple times.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…_parse_as_type_expression()
Specifically:
- If you set MYPY_TYPEFORM_PROFILE_FULL_PARSE environment variable,
mypy will output a .tsv to that filepath which characterizes the
kinds of Expressions that try_parse_as_type_expression() in semanal.py
was forced to do a full parse of, which was not rejected early.
- A misc/analyze_typeform_full_parse_profile.py script is added which
takes those .tsvs and prints an expression-time summary (by total time)
plus top-N descriptors per FAIL class.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@davidfstr