René's URL Explorer Experiment


Title: Exponential increase in compile time and memory usage · Issue #38339 · microsoft/TypeScript · GitHub

Open Graph Title: Exponential increase in compile time and memory usage · Issue #38339 · microsoft/TypeScript

X Title: Exponential increase in compile time and memory usage · Issue #38339 · microsoft/TypeScript

Description: This bug report is a follow-up to this tweet where I write about OOM crashes in 3.9.1-rc. Daniel Rosenwasser (@DanielRosenwasser) asked me to report an issue, but I find it really hard to narrow it down. I have a project with ~2k lines o...

Open Graph Description: This bug report is a follow-up to this tweet where I write about OOM crashes in 3.9.1-rc. Daniel Rosenwasser (@DanielRosenwasser) asked me to report an issue, but I find it really hard to narrow it...

X Description: This bug report is a follow-up to this tweet where I write about OOM crashes in 3.9.1-rc. Daniel Rosenwasser (@DanielRosenwasser) asked me to report an issue, but I find it really hard to narrow it...

Opengraph URL: https://github.com/microsoft/TypeScript/issues/38339

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Exponential increase in compile time and memory usage","articleBody":"> This bug report is a follow-up to [this tweet](https://twitter.com/squidfunk/status/1256149893007147009) where I write about OOM crashes in 3.9.1-rc. @DanielRosenwasser asked me to report an issue, but I find it really hard to narrow it down.\r\n\r\nI have a project with ~2k lines of code. It uses another internal package with ~18k lines of code. The problem is that the compiler doesn't terminate anymore. I then tried to compile a subset of the project (which is a recursive decent parser, BTW), which runs in under 6 seconds. If I add more and more files, it will get slower and slower to a point where it will run into OOM. The interesting thing is that there's no big bump in files, lines, types, instantiations or symbols:\r\n\r\n```\r\nFiles:             1588      1597      1600\r\nLines:            65199     80674     81049\r\nNodes:           278678    349628    350339\r\nIdentifiers:      90620     91032     91288\r\nSymbols:          64556    465900    478162\r\nTypes:             3027    109800    134328\r\nInstantiations:   31435    115295    222586\r\nMemory used:    125785K   295562K   952063K\r\nI/O read:         0.19s     0.13s     0.90s\r\nI/O write:        0.02s     0.05s     0.06s\r\nParse time:       3.78s     3.27s     4.77s\r\nBind time:        0.80s     0.78s     1.07s\r\nCheck time:       0.96s     5.37s    94.43s\r\nEmit time:        0.25s     0.74s     0.77s\r\nTotal time:       5.79s    10.15s   101.04s\r\n```\r\n\r\nYes, there are twice as many instantiations, which I assume results from the use of rather large discriminated unions (.e.g when restructuring them), but the increase in memory is almost three times as high. The CPU profile when compiling looks like this:\r\n\r\n![EW69odEWkAIX0SS](https://user-images.githubusercontent.com/932156/81065729-53512e80-8edc-11ea-82fe-90d5b394c817.png)\r\n\r\nMy current guess is that the exponential increase is somehow related to __Instantiations ⨉ Instantiations__, as most of the time is spent in `someTypeRelatedToType`.\r\n\r\nI tried breaking it down to a reproducible case, but as the project with which I'm experiencing this issue is not Open Source, stripping everything down takes too much time. I understand that this is not an actionable error report, but maybe there's an obvious reason why this recent change in behavior may be causing this. If not, feel free to close it\r\n\r\n**TypeScript Version:**  3.9.1-rc\r\n**Search Terms:** crash, out of memory, oom\r\n\r\n**Code** \r\n\r\nCould not be provided\r\n\r\n**Expected behavior:**\r\n\r\nTypeScript compiles the code\r\n\r\n**Actual behavior:**\r\n\r\nTypeScript runs out of memory\r\n\r\n**UPDATE**:\r\n\r\nI managed to get all packages to build with 3.9.1 by removing mapped discriminated union types, i.e. functions with signatures like `function\u003cT extends FooKind>(kind: T): FooLike\u003cT>`, whereas `FooLike\u003cT>` uses conditionals to select a specific type from a huge union with ~1k types. Build times now are:\r\n\r\n```\r\npackage-c          3.8.3     3.9.1\r\n\r\nFiles:              1626      1628\r\nLines:             84005     84000\r\nNodes:            357333    357139\r\nIdentifiers:       93411     93314\r\nSymbols:          488307    487405\r\nTypes:            128763    124300\r\nInstantiations:        -    167777\r\nMemory used:    1092025K   979008K\r\nI/O read:          0.17s     0.33s\r\nI/O write:         0.13s     0.22s\r\nParse time:        3.29s     5.44s\r\nBind time:         1.20s     1.64s\r\nCheck time:       60.46s    92.90s\r\nEmit time:         2.41s     2.85s\r\nTotal time:       67.37s   102.82s\r\n\r\npackage-b          3.8.3     3.9.1\r\n\r\nFiles:              1588      1590\r\nLines:             64154     64149\r\nNodes:            276974    276780\r\nIdentifiers:       89681     89584\r\nSymbols:           64608     64983\r\nTypes:              3484      3621\r\nInstantiations:        -      9232\r\nMemory used:     131259K   130999K\r\nI/O read:          0.25s     0.22s\r\nI/O write:         0.10s     0.08s\r\nParse time:        4.70s     4.62s\r\nBind time:         0.99s     1.14s\r\nCheck time:        0.99s     1.12s\r\nEmit time:         1.16s     1.38s\r\nTotal time:        7.83s     8.26s\r\n\r\npackage-a          3.8.3     3.9.1\r\n\r\nFiles:              1577      1579\r\nLines:            115025    115020\r\nNodes:            329307    329113\r\nIdentifiers:       88729     88632\r\nSymbols:          154484    151390\r\nTypes:             45980     45135\r\nInstantiations:        -     36085\r\nMemory used:     372082K   274693K\r\nI/O read:          0.27s     1.54s\r\nI/O write:         3.98s     3.98s\r\nParse time:        6.17s     7.64s\r\nBind time:         1.63s     1.77s\r\nCheck time:       21.55s     4.72s\r\nEmit time:        13.94s    15.12s\r\nTotal time:       43.29s    29.25s\r\n```","author":{"url":"https://github.com/squidfunk","@type":"Person","name":"squidfunk"},"datePublished":"2020-05-05T14:06:41Z","url":"https://github.com/microsoft/TypeScript/issues/38339"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:4a5af765-f7a3-af8a-cbb8-9ab8cd88c76c
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idC8AC:3DA1E8:5DF99C:7D1FAA:6B01A235
html-safe-noncece7562a35ff1299905d2d8d1f0111ec28739dc8f57d72e5c697cdafb5512e58f
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDOEFDOjNEQTFFODo1REY5OUM6N0QxRkFBOjZCMDFBMjM1IiwidmlzaXRvcl9pZCI6IjI2NTI3NTc4MDE2NTg1ODk3NDkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacab58f84ee864406a5e5e70ce8178b8f3ffa8efea707d2b9874ead410e575a4bd
hovercard-subject-tagissue:612630795
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/TypeScript/38339/issue_layout
twitter:imagehttps://opengraph.githubassets.com/2dd576dce2e936da2d11dc6bd9883d97fe95884e6e038b2cca5716b061dc8dc6/microsoft/TypeScript/issues/38339
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/2dd576dce2e936da2d11dc6bd9883d97fe95884e6e038b2cca5716b061dc8dc6/microsoft/TypeScript/issues/38339
og:image:altThis bug report is a follow-up to this tweet where I write about OOM crashes in 3.9.1-rc. Daniel Rosenwasser (@DanielRosenwasser) asked me to report an issue, but I find it really hard to narrow it...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamesquidfunk
hostnamegithub.com
expected-hostnamegithub.com
Nonecc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c
turbo-cache-controlno-preview
go-importgithub.com/microsoft/TypeScript git https://github.com/microsoft/TypeScript.git
octolytics-dimension-user_id6154722
octolytics-dimension-user_loginmicrosoft
octolytics-dimension-repository_id20929025
octolytics-dimension-repository_nwomicrosoft/TypeScript
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id20929025
octolytics-dimension-repository_network_root_nwomicrosoft/TypeScript
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release8c77c9e8439031ad54c75a250694842892f693e1
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/microsoft/TypeScript/issues/38339#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F38339
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F38339
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=microsoft%2FTypeScript
Reloadhttps://github.com/microsoft/TypeScript/issues/38339
Reloadhttps://github.com/microsoft/TypeScript/issues/38339
Reloadhttps://github.com/microsoft/TypeScript/issues/38339
microsofthttps://github.com/microsoft
TypeScripthttps://github.com/microsoft/TypeScript
Codehttps://github.com/microsoft/TypeScript
Issues5k (5k)https://github.com/microsoft/TypeScript/issues
Pull requests312 (312)https://github.com/microsoft/TypeScript/pulls
Actionshttps://github.com/microsoft/TypeScript/actions
Projectshttps://github.com/microsoft/TypeScript/projects
Wikihttps://github.com/microsoft/TypeScript/wiki
Security and qualityhttps://github.com/microsoft/TypeScript/security
Insightshttps://github.com/microsoft/TypeScript/insights
https://github.com/microsoft/TypeScript
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/38339
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/38339
Exponential increase in compile time and memory usagehttps://github.com/microsoft/TypeScript/issues/38339#top
https://github.com/amcasey
Needs InvestigationThis issue needs a team member to investigate its status.https://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Needs%20Investigation%22
TypeScript 4.0.1https://github.com/microsoft/TypeScript/milestone/123
https://github.com/squidfunk
Martin Donath (squidfunk)https://github.com/squidfunk
on May 5, 2020https://github.com/microsoft/TypeScript/issues/38339#issue-612630795
this tweethttps://twitter.com/squidfunk/status/1256149893007147009
Daniel Rosenwasser (@DanielRosenwasser)https://github.com/DanielRosenwasser
https://user-images.githubusercontent.com/932156/81065729-53512e80-8edc-11ea-82fe-90d5b394c817.png
Nexthttps://github.com/microsoft/TypeScript/issues/38339?timeline_page=1
https://github.com/amcasey
Andrew Casey (amcasey)https://github.com/amcasey
on May 5, 2020https://github.com/microsoft/TypeScript/issues/38339#issuecomment-624360922
Martin Donath (@squidfunk)https://github.com/squidfunk
https://github.com/squidfunk
Martin Donath (squidfunk)https://github.com/squidfunk
on May 6, 2020https://github.com/microsoft/TypeScript/issues/38339#issuecomment-624472857
https://github.com/squidfunk
Martin Donath (squidfunk)https://github.com/squidfunk
on May 6, 2020https://github.com/microsoft/TypeScript/issues/38339#issuecomment-624476171
https://github.com/squidfunk
Martin Donath (squidfunk)https://github.com/squidfunk
on May 6, 2020https://github.com/microsoft/TypeScript/issues/38339#issuecomment-624524943
https://github.com/squidfunk
Martin Donath (squidfunk)https://github.com/squidfunk
on May 6, 2020https://github.com/microsoft/TypeScript/issues/38339#issuecomment-624552394
https://github.com/squidfunk
Martin Donath (squidfunk)https://github.com/squidfunk
on May 6, 2020https://github.com/microsoft/TypeScript/issues/38339#issuecomment-624618710
https://github.com/squidfunk/typescript-issue-38339-reprohttps://github.com/squidfunk/typescript-issue-38339-repro
https://github.com/amcasey
Andrew Casey (amcasey)https://github.com/amcasey
on May 6, 2020https://github.com/microsoft/TypeScript/issues/38339#issuecomment-624893003
https://github.com/amcasey
Andrew Casey (amcasey)https://github.com/amcasey
on May 6, 2020https://github.com/microsoft/TypeScript/issues/38339#issuecomment-624895307
https://github.com/squidfunk
Martin Donath (squidfunk)https://github.com/squidfunk
on May 7, 2020https://github.com/microsoft/TypeScript/issues/38339#issuecomment-625090089
https://github.com/amcasey
Andrew Casey (amcasey)https://github.com/amcasey
on May 7, 2020https://github.com/microsoft/TypeScript/issues/38339#issuecomment-625414836
Daniel Rosenwasser (@DanielRosenwasser)https://github.com/DanielRosenwasser
#37785https://github.com/microsoft/TypeScript/pull/37785
https://github.com/amcasey
Andrew Casey (amcasey)https://github.com/amcasey
on May 7, 2020https://github.com/microsoft/TypeScript/issues/38339#issuecomment-625495909
Anders Hejlsberg (@ahejlsberg)https://github.com/ahejlsberg
Martin Donath (@squidfunk)https://github.com/squidfunk
https://github.com/squidfunk
Martin Donath (squidfunk)https://github.com/squidfunk
on May 8, 2020https://github.com/microsoft/TypeScript/issues/38339#issuecomment-625668149
#38399https://github.com/microsoft/TypeScript/issues/38399
Daniel Rosenwasser (@DanielRosenwasser)https://github.com/DanielRosenwasser
#37785https://github.com/microsoft/TypeScript/pull/37785
https://github.com/squidfunk
Martin Donath (squidfunk)https://github.com/squidfunk
on May 8, 2020https://github.com/microsoft/TypeScript/issues/38339#issuecomment-625681303
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
Needs InvestigationThis issue needs a team member to investigate its status.https://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Needs%20Investigation%22
on May 8, 2020https://github.com/microsoft/TypeScript/issues/38339#event-3318609522
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
Anders Hejlsberg (ahejlsberg)https://github.com/ahejlsberg
on May 8, 2020https://github.com/microsoft/TypeScript/issues/38339#event-3318609623
https://github.com/amcasey
Andrew Casey (amcasey)https://github.com/amcasey
on Jun 30, 2020https://github.com/microsoft/TypeScript/issues/38339#issuecomment-651916329
Anders Hejlsberg (@ahejlsberg)https://github.com/ahejlsberg
Alejandro Corredor (@aecorredor)https://github.com/aecorredor
Andrew Casey (amcasey)https://github.com/amcasey
Andrew Casey (amcasey)https://github.com/amcasey
Anders Hejlsberg (ahejlsberg)https://github.com/ahejlsberg
on Jun 30, 2020https://github.com/microsoft/TypeScript/issues/38339#event-3498716433
https://github.com/aecorredor
Alejandro Corredor (aecorredor)https://github.com/aecorredor
on Jun 30, 2020https://github.com/microsoft/TypeScript/issues/38339#issuecomment-651977987
Anders Hejlsberg (@ahejlsberg)https://github.com/ahejlsberg
Alejandro Corredor (@aecorredor)https://github.com/aecorredor
#39284 (comment)https://github.com/microsoft/TypeScript/issues/39284#issuecomment-651815195
Andrew Casey (amcasey)https://github.com/amcasey
completedhttps://github.com/microsoft/TypeScript/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Jun 30, 2020https://github.com/microsoft/TypeScript/issues/38339#event-3499352610
Andrew Casey (amcasey)https://github.com/amcasey
on Jun 30, 2020https://github.com/microsoft/TypeScript/issues/38339#event-3499352956
https://github.com/aecorredor
Alejandro Corredor (aecorredor)https://github.com/aecorredor
on Jun 30, 2020https://github.com/microsoft/TypeScript/issues/38339#issuecomment-652094161
Andrew Casey (@amcasey)https://github.com/amcasey
https://github.com/amcasey
Andrew Casey (amcasey)https://github.com/amcasey
on Jul 1, 2020https://github.com/microsoft/TypeScript/issues/38339#issuecomment-652136201
Alejandro Corredor (@aecorredor)https://github.com/aecorredor
https://github.com/aecorredor
Alejandro Corredor (aecorredor)https://github.com/aecorredor
on Jul 28, 2020https://github.com/microsoft/TypeScript/issues/38339#issuecomment-664763528
Andrew Casey (@amcasey)https://github.com/amcasey
#39398https://github.com/microsoft/TypeScript/issues/39398
https://github.com/millsp
pierre (millsp)https://github.com/millsp
on Jul 30, 2020https://github.com/microsoft/TypeScript/issues/38339#issuecomment-666381803
#39094https://github.com/microsoft/TypeScript/pull/39094
ts-toolbelthttps://github.com/millsp/ts-toolbelt
https://github.com/amcasey
Andrew Casey (amcasey)https://github.com/amcasey
on Jul 31, 2020https://github.com/microsoft/TypeScript/issues/38339#issuecomment-667239081
#39398https://github.com/microsoft/TypeScript/issues/39398
Martin Donath (@squidfunk)https://github.com/squidfunk
https://github.com/millsp
pierre (millsp)https://github.com/millsp
on Aug 2, 2020https://github.com/microsoft/TypeScript/issues/38339#issuecomment-667726602
https://github.com/k-yle
Kyℓe Hensel (k-yle)https://github.com/k-yle
on Aug 3, 2020https://github.com/microsoft/TypeScript/issues/38339#issuecomment-667749987
pierre (@millsp)https://github.com/millsp
https://github.com/squidfunk
Martin Donath (squidfunk)https://github.com/squidfunk
on Aug 3, 2020https://github.com/microsoft/TypeScript/issues/38339#issuecomment-667863115
Andrew Casey (@amcasey)https://github.com/amcasey
Andrew Casey (amcasey)https://github.com/amcasey
completedhttps://github.com/microsoft/TypeScript/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Aug 3, 2020https://github.com/microsoft/TypeScript/issues/38339#event-3616853526
Sign up for freehttps://github.com/signup?return_to=https://github.com/microsoft/TypeScript/issues/38339
Sign in to commenthttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/38339
Andrew Casey (amcasey)https://github.com/amcasey
Needs InvestigationThis issue needs a team member to investigate its status.https://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Needs%20Investigation%22
TypeScript 4.0.1https://github.com/microsoft/TypeScript/milestone/123
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.