Repository: godot
Issue: GDScript parsing causes large editor stalls
Labels: bug,topic:gdscript,performance

### Godot version

v4.1.stable.official [970459615]

### System information

Windows 10

### Issue description

Some part of the GDScript parsing routine is run on EditorSettings change, after idle parse, and when offering code completion suggestions. In Godot 3.5 this either isn't run or is significantly faster as to not severely impact editor performance.

In Godot 4.1 editor performance is heavily impacted by "code complexity." Below is a video of I/O and CPU usage from changing EditorSettings and typing with a code_completion_delay of 0.01.

NOTE: My CPU is an i7-10700K so the 6.2% CPU usage is Godot maxing out 1 core.

<details><summary>C is an autoload file with just a few properties that point to "complex" Class instances</summary>

![image](https://github.com/godotengine/godot/assets/3820082/02b6c9a1-3d3e-42d2-aad6-7e8734db00bf)

![image](https://github.com/godotengine/godot/assets/3820082/16b67309-8bc2-4dd1-aa7a-a81edab9725c)

</details>

<details><summary>The complex classes are just a bunch of properties</summary>

![image](https://github.com/godotengine/godot/assets/3820082/7e45c608-5ea7-4b2f-b397-cb5b3cd38a07)

</details> 

<details><summary>EditorSettings changes cause this stalling</summary>

https://github.com/godotengine/godot/assets/3820082/6d530713-270b-4a1a-a792-5463fa3b3bbd

</details> 

<details><summary>Code completion suggestions cause this stalling</summary>

https://github.com/godotengine/godot/assets/3820082/589b1a54-5a02-4e93-bdf7-924f6e253a2c

</details>

<details><summary>While these examples are contrived, the performance on my actual project is quite bad.</summary>

https://github.com/godotengine/godot/assets/3820082/99e6cf75-93e0-46de-8ba7-3b4d8ab90464

</details> 

<details><summary>The same codebase in Godot 3.5 has no performance issues (it might be stalling only after pressing close)</summary>

https://github.com/godotengine/godot/assets/3820082/aabd88c5-bc83-4d21-b3cf-f565ae6a8765

https://github.com/godotengine/godot/assets/3820082/3395d9b8-dc37-4741-9a47-06f5a700f697

</details> 

This stalling also causes input events to be dropped or late, so if I do things that aren't typing about idle_parse_delay seconds after writing code they can get messed up during this stall, like using my mouse to select text or hitting ctrl + f. I can't reliably reproduce these for a video but they're common.

Semi-relevant discussion thread https://github.com/godotengine/godot-proposals/discussions/7487

### Profiling

I downloaded a version of 4.0.3 with debugging symbols and confirmed moving the code completion delay slider around (changing EditorSettings) causes a validate call if any scripts are open in the script editor, but code completion seems to just be particularly slow.

<details><summary>VerySleepy call stacks</summary>

When changing EditorSettings
![image](https://github.com/godotengine/godot/assets/3820082/d64a4859-6f9a-4fd2-92a9-27deb1baf920)

When triggering code completion with 0.01 delay
![image](https://github.com/godotengine/godot/assets/3820082/8931f2aa-4531-47cb-bf35-d536498e041e)

</details>

### Steps to reproduce

Have a relatively "complex" codebase and attempt to change code complete delay or idle parse delay EditorSettings, or set code completion delay to 0.01 and start typing to trigger it.

MRPs attached.

### Minimal reproduction project

Here's an MRP for Godot 4.1: [gdscript-parse-mrp.zip](https://github.com/godotengine/godot/files/12339167/gdscript-parse-mrp.zip)
Here's an MRP for Godot 3.5: [gdscript-parse-mrp3.zip](https://github.com/godotengine/godot/files/12339168/gdscript-parse-mrp3.zip)

I get basically no CPU usage or disk thrashing from the Godot 3.5 MRP.