Skip to content

[ty] Test cycle detector#24314

Draft
charliermarsh wants to merge 4 commits intomainfrom
crmarsh/ty-recursive-alias-stack-overflow
Draft

[ty] Test cycle detector#24314
charliermarsh wants to merge 4 commits intomainfrom
crmarsh/ty-recursive-alias-stack-overflow

Conversation

@charliermarsh
Copy link
Copy Markdown
Member

No description provided.

@astral-sh-bot astral-sh-bot bot added the ty Multi-file analysis & type inference label Mar 30, 2026
@astral-sh-bot
Copy link
Copy Markdown

astral-sh-bot bot commented Mar 30, 2026

Typing conformance results

No changes detected ✅

Current numbers
The percentage of diagnostics emitted that were expected errors held steady at 86.61%. The percentage of expected errors that received a diagnostic held steady at 81.56%. The number of fully passing files held steady at 70/132.

@astral-sh-bot
Copy link
Copy Markdown

astral-sh-bot bot commented Mar 30, 2026

Memory usage report

Memory usage unchanged ✅

Comment on lines +252 to +254
/// Materialization is the only mapping mode that needs to visit the same type under two different
/// mappings within a single recursive call chain (`Top` and `Bottom`). Keep separate cycle caches
/// for those modes so invariant checks can safely reuse one visitor.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not actually sure we need a cache for apply_type_mapping at all. I don't think it's nearly as effective an optimisation as it is for has_relation_to, and as you point out it's not very robust. I've been wondering for a bit if we should try ripping out the caching infrastructure from the CycleDetector and make the cycle detectors in types/relation.rs newtype wrappers around CycleDetector that add caching

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#24017 is also a way of getting rid of the problematica caching from apply_type_mapping, which works from the opposite premise of what I just said above (that apply_type_mapping is the "special" method that needs to be treated specially), but I've since come to believe that the special method is probably really has_relation_to; I'm not sure any other method that has cycle detectors really needs the caching infrastructure

@astral-sh-bot
Copy link
Copy Markdown

astral-sh-bot bot commented Mar 30, 2026

ecosystem-analyzer results

Lint rule Added Removed Changed
invalid-await 0 40 0
invalid-return-type 0 1 0
Total 0 41 0

Changes in flaky projects detected. Raw diff output excludes flaky projects; see the HTML report for details.

Full report with detailed diff (timing results)

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 30, 2026

Merging this PR will degrade performance by 16.32%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

❌ 8 regressed benchmarks
✅ 39 untouched benchmarks
⏩ 60 skipped benchmarks1

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
WallTime static_frame 21.4 s 22.5 s -5.11%
WallTime pandas 68.8 s 72.7 s -5.35%
WallTime altair 5.1 s 5.3 s -4.77%
Simulation ty_micro[typeis_narrowing] 173.2 ms 191 ms -9.32%
Simulation ty_micro[large_union_narrowing] 497.8 ms 530.7 ms -6.21%
Simulation ty_micro[many_enum_members_2] 172.6 ms 206.3 ms -16.32%
WallTime pydantic 7.4 s 7.8 s -4.99%
WallTime colour_science 58.6 s 61.8 s -5.21%

Comparing crmarsh/ty-recursive-alias-stack-overflow (9c476e2) with main (e871de4)

Open in CodSpeed

Footnotes

  1. 60 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

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

Labels

ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants