Open roryscot opened 4 weeks ago
This seems to be very similar to #56081 (sorta) / #52345 / #55948, something I tried to help fix a while back. This repo seems to spend basically all of its time in removeStringLiteralsMatchedByTemplateLiterals
, which means there's some truly massive union of literals being processed.
That being said, I'm confused as to this repro; it mentions an eslint error showing up (not TS related?), and the above perf problem was coming from diagnostics themselves, not semantic highlighting. Just running tsc
in the repro takes a very long time. Is the problem the perf in general?
The eslint error is only reflective of a performance issue, yes. Though the perf issue seems to originate in TS--specifically in the Schema. I thought it might be a recursion issue.
I'm not sure where this is happening, but something in this example is attempting to create a union with 628,109 types, 1,733 of which are template literals, and 626,376 are string literals that have to be matched against those template literals. That means needing to do 1,085,509,608 string-to-string-literal inferences.
Adding in a limiter to bail out when this situation happens points here:
src/components/UserProfile/UserProfile.tsx:14:38 - error TS2590: Expression produces a union type that is too complex to represent.
14 const { data: profiles } = await client.models.UserProfile.list({
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 filter: {
~~~~~~~~~~~~~~~
...
19 },
~~~~~~~~
20 });
~~~~~~
Just to show what those strings are, if that helps you narrow down the bad code:
healthGoals.userProfile.automatedUpdates.userProfile.privacySettings.userProfile.predictiveAnalytics.*
healthGoals.userProfile.automatedUpdates.userProfile.privacySettings.userProfile.articles.*
healthGoals.userProfile.automatedUpdates.userProfile.privacySettings.userProfile.medicationLogs.*
healthGoals.userProfile.automatedUpdates.userProfile.privacySettings.userProfile.symptomLogs.*
healthGoals.userProfile.automatedUpdates.userProfile.privacySettings.userProfile.contraceptiveMethods.*
healthGoals.userProfile.automatedUpdates.userProfile.privacySettings.userProfile.contraceptiveReminders.*
healthGoals.userProfile.automatedUpdates.userProfile.privacySettings.userProfile.ovulationTests.*
healthGoals.userProfile.automatedUpdates.userProfile.privacySettings.userProfile.basalBodyTemperatures.*
healthGoals.userProfile.automatedUpdates.userProfile.privacySettings.userProfile.menstrualHealthInsights.*
healthGoals.userProfile.automatedUpdates.userProfile.privacySettings.userProfile.ovulationPredictions.*
healthGoals.userProfile.automatedUpdates.userProfile.privacySettings.userProfile.ovulationCycles.*
healthGoals.userProfile.automatedUpdates.userProfile.privacySettings.userProfile.birthday.*
healthGoals.userProfile.automatedUpdates.userProfile.privacySettings.userProfile.avatar.*
healthGoals.userProfile.automatedUpdates.userProfile.privacySettings.userProfile.profileOwner.*
healthGoals.userProfile.automatedUpdates.userProfile.privacySettings.userProfile.fertilityWindows.*
healthGoals.userProfile.automatedUpdates.userProfile.privacySettings.userProfile.progressReports.*
healthGoals.userProfile.automatedUpdates.userProfile.privacySettings.userProfile.uuid.*
healthGoals.userProfile.automatedUpdates.userProfile.privacySettings.userProfile.OvulationCycleAnalysis.*
healthGoals.userProfile.automatedUpdates.userProfile.privacySettings.userProfile.id.*
healthGoals.userProfile.automatedUpdates.userProfile.privacySettings.userProfile.email.*
healthGoals.userProfile.automatedUpdates.userProfile.privacySettings.updatedAt
healthGoals.userProfile.automatedUpdates.userProfile.privacySettings.createdAt
healthGoals.userProfile.automatedUpdates.userProfile.privacySettings.settingValue
healthGoals.userProfile.automatedUpdates.userProfile.privacySettings.settingName
Can you try the build on https://github.com/microsoft/TypeScript/pull/59759#issuecomment-2310657198 to see if that fixes things in general?
It does not seem to make a difference
Hm, okay. I rechecked the profile for just a completion call, and most of the time is now spent in auto-imports.
vscode-profile-2024-08-26-11-20-10.cpuprofile
In my logs, I do not see the call from the issue title taking time:
Perf 2101 [11:30:31.389] 7::encodedSemanticClassifications-full: elapsed time (in milliseconds) 4.7975
But do see completion being slow:
Perf 2123 [11:30:38.555] 11::completionInfo: elapsed time (in milliseconds) 7163.8768
Can you turn on logging and send tsserver logs?
🔎 Search Terms
@RyanCavanaugh requested that I create a new issue
🕗 Version & Regression Information
⏯ Playground Link
No response
💻 Code
npm i
Command + .
)The warning
React Hook useEffect has a missing dependency: 'getProfile'. Either include it or remove the dependency array.eslint[react-hooks/exhaustive-deps](https://github.com/facebook/react/issues/14920)
should appear on line 26🙁 Actual behavior
2024-08-15 18:57:48.766 [trace] <semantic> Response received: encodedSemanticClassifications-full (210). Request took 155445 ms. Success: true { "spans": [ 467, 11, 2817, 493, 5, 2560, 500, 4, 2089, 509, 10, 2816, 520, 11, 2056, 543, 7, 2089, 552, 10, 2857, 566, 8, 2816, 575, 12, 1536, 600, 6, 2089, 609, 10, 2816, 620, 21, 2056, 686, 10, 2857, 699, 11, 2816, 737, 4, 2560, 743, 8, 2089, 762, 6, 2088, 769, 6, 2560, 776, 11, 2560, 788, 4, 3072, 801, 6, 2561, 819, 5, 2561, 838, 2, 2561, 842, 4, 2088, 848, 10, 2560, 899, 8, 2088, 908, 6, 2576, 918, 10, 2856, 929, 8, 2088, 949, 6, 2088, 956, 6, 2560, 963, 11, 2560, 976, 4, 2088, 987, 9, 2816, 1009, 10, 2856, 1029, 6, 2088, 1036, 6, 2560, 1043, 11, 2560, 1056, 4, 2088, 1124, 7, 2088, 1160, 4, 2561, 1178, 7, 2561, 1205, 8, 2561, 1240, 5, 2561, 1259, 7, 2561, 1286, 8, 2561, 1321, 12, 2561, 1347, 7, 2561, 1374, 8, 2561, 1409, 6, 2561, 1429, 7, 2561, 1456, 8, 2561 ], "endOfLineState": 0 }
encodedSemanticClassifications-full took almost a minute and an half.
🙂 Expected behavior
encodedSemanticClassifications-full should take less than a few seconds.
Additional information about the issue
When I remove the import for Schema, everything seems to work as expected. The Schema is a somewhat complex generated type whose definition is here.