Repository: godot
Issue: Very slow project/editor opening in Godot 4
Labels: bug,topic:rendering,confirmed,regression,performance

**Godot version:**
4.0.dev.custom_build. 494bf38c7
GLES 2 - tested 14.01.2020

**OS/device including version:**
Ubuntu 20.04
Nvidia 970 440.83, i7 4770 4/8
Hotspot -v1.3.0-27-g61f1314 


**Issue description:**
Opening and closing empty project in editor with command `godot -e -q` take a lot of more time than previous versions.

<details> 
  <summary>2020 11 results</summary>

RESULTS FROM 06.11.2020
|Version|Opening Time|Memory usage in editor|
|-|-|-|
|Godot 3.2 |   4.2s| 135 MB |
|Godot 4.0 GLES 2| 8.2s | 403 MB |
|Godot 4.0 (494bf38c7) | 13.2s| 340 MB |
|Godot 3.2 + Sanitizers | 13.1s| - | 
|Godot 4.0 (494bf38c7) + Sanitizers | 41s| - | 

</details>

<details> 
  <summary>25.07.2020 results</summary>
RESULTS FROM 25.07.2020
|Version|Opening Time|
|-|-|
|Godot 3.4 (6d58ea6ce)| 5.2s |
|Godot 3.4 (6d58ea6ce) + Sanitizers| 13.7s |
|Godot 4.0 (b918c4c3c) - first run | 13.9s |
|Godot 4.0 (b918c4c3c) - second run | 10.4s |
|Godot 4.0 (b918c4c3c) + Sanitizers - first run| 53,4s |
|Godot 4.0 (b918c4c3c) + Sanitizers - second run| 33s |
</details>

RESULTS FROM 28.11.2022 - opening and closing empty project in editor

Dev debug builds
|Version|Opening Time|
|-|-|
|Godot 3.6 (6d58ea6ce) GLES3 | 5.2s |
|Godot 3.6 (6d58ea6ce) GLES3 + Sanitizers| 13.7s |
|Godot 4.0 (71f5bb391) Vulkan - first run | 47.4s |
|Godot 4.0 (71f5bb391) Vulkan - second run | 27.4s |
|Godot 4.0 (71f5bb391) Headless | 23s |
|Godot 4.0 (71f5bb391) Vulkan + Sanitizers - first run| 129s |
|Godot 4.0 (71f5bb391) Vulkan + Sanitizers - second run| 110s |

optimized builds(downloaded from official site)
|Version|Opening Time|
|-|-|
|Godot 3.5.1 GLES3 | 7.7s |
|Godot 4.0 beta 6 Vulkan | 10.8s |
|Godot 4.0 beta 6 Headless | 8.2s |

This makes it very difficult to test and develop the engine, especially when you start it with Address Sanitizer for example.

Most time spends on compiling shaders, which seems for me that partially can be avoidable by caching it or even compiling it when compiling Godot(not sure if this is possible).

Running Valgrind in one small project take almost 10 minutes
<details> 
  <summary>2020 11 results</summary>

CPU Cycles in Godot 3.2
![Zrzut ekranu z 2020-11-06 09-58-37](https://user-images.githubusercontent.com/41945903/98349060-d3865700-2019-11eb-8122-589c771a3ea4.png)

CPU Cycles in Godot 4.0
![Zrzut ekranu z 2020-11-06 09-56-46](https://user-images.githubusercontent.com/41945903/98349180-fa448d80-2019-11eb-9b44-2b65585ae54b.png)

CPU Cycles in Godot 4.0 GLES 2
![Zrzut ekranu z 2021-01-14 14-52-31](https://user-images.githubusercontent.com/41945903/104599552-3cbcc300-5678-11eb-86af-276530c50b0b.png)

</details>
Graphs
Godot 4 Beta 6 Dev Hadless:

![Screenshot from 2022-11-28 08-56-29](https://user-images.githubusercontent.com/41945903/204231780-8c77a0d1-a10d-40a8-a6a9-f8f324aff35d.png)

Godot 4 Beta 6 Dev Vulkan
![Screenshot from 2022-11-28 09-19-58](https://user-images.githubusercontent.com/41945903/204232514-2116bcbb-030d-4b16-9f6e-306cd6a9a5eb.png)

Godot 3.6 - 6d58ea6ce GLES 3
![Screenshot from 2022-11-28 09-30-51](https://user-images.githubusercontent.com/41945903/204232602-6bb03e10-e635-4100-86f1-f6f0625a08e0.png)


**Steps to reproduce:**
To get perf data just execute this command(path must be changed)
```
perf record -o /home/rafal/perf.data --call-graph dwarf --aio --sample-cpu /usr/bin/godot4 -e -q
```
And then open it in latest version of Hotspot- https://github.com/KDAB/hotspot/releases