GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — only build intersection props that can reduce it to never by maschwenk · Pull Request #64476 · microsoft/TypeScript Conversation
|
| heap, 4 checkers | peak rss, 4 checkers | check, 4 checkers | heap, single | check, single | |
|---|---|---|---|---|---|
| mui-docs | −41.8% | −38.2% | −38.9% | −33.7% | −28.8% |
| Compiler-Unions | −4.7% | −3.0% | 0.0% | −5.1% | −3.8% |
| webpack | −2.5% | +1.9% | −3.9% | −2.9% | −2.7% |
| xstate-main | −1.2% | −0.9% | +3.6% | −0.9% | +0.5% |
| vscode | −0.4% | −0.7% | −2.2% | −0.3% | +0.8% |
| Compiler | −1.8% | −1.0% | +1.4% | −0.4% | −1.2% |
mui-docs gets the big win since its styling types build some really big intersections. the check times on the small projects are within run to run noise. raw results and scripts: https://gist.github.com/maschwenk/c83d9185c6961b6fb43d7d071ef39cf6
i also tried an even simpler check, create the property for any name more than one constituent has (d33ab85). less code, but on our 37k-file program it held 0.28 GiB more heap, so i went back
full go suite passes (also multiple checkers and -race), lint and format are clean. added intersectionNeverReductionByProperty.ts with baselines generated on unmodified main. it covers literal/boolean/template literal discriminants, optional and never props, private vs protected, instantiations of the same generic class, generic aliases and type params with union constraints
go test ./... in tsc, same thing hereby test runs)hereby linthereby check:formatused claude code to help write this, ive reviewed it
Sorry, something went wrong.
There was an error while loading. Please reload this page.
getReducedType decided whether an intersection reduces to never by creating the combined property of every property name of every constituent (getPropertiesOfUnionOrIntersectionType). In large intersections most of those synthetic properties, and the intersections of their types, are never used again. Only a combination of distinct constituent properties where one has a literal type (a discriminant), a private property, or a constituent property that is itself such a combination can satisfy isNeverReducedProperty. isNeverReducedIntersection now collects the constituent properties of each name as createUnionOrIntersectionProperty does, including comparing instantiations of the same property, and only creates the combined property for those names. When the properties of the intersection are already resolved it checks them as before. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Instead of collecting the constituent properties of every name the way createUnionOrIntersectionProperty does, create the combined property for any name that more than one constituent has. The combined property of a name only one constituent has is that constituent's own property, which can only reduce the intersection if it already combines the properties of a union. This creates more combined properties than before, but is much simpler and saves the per-name lookups in every constituent. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This reverts d33ab85. The simpler check was faster on the typescript-benchmarking projects, but on a 37k-file program it created 356k more symbols and held 0.28 GiB more heap (about 1.3 GiB more peak RSS with 4 checkers), which is the problem this change is for. Co-Authored-By: Claude Opus 5.5 <[email protected]>
isNeverReducedIntersection re-implemented how createUnionOrIntersectionProperty collects each constituent's property of a name. That loop is now collectUnionOrIntersectionPropertyParts, and both use it. From what it collects, isNeverReducedIntersection checks whether the combined property could satisfy isNeverReducedProperty (it needs a literal-typed or a private constituent property) before creating it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Max Schwenk (@maschwenk) I have a simpler implementation in #64499 with equally nice results. Thanks much for the research! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Anders Hejlsberg (@ahejlsberg) shall I close this out? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Yes, #64499 is already in main. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
checker builds member tables and intersection props it never uses
There was an error while loading. Please reload this page.