If the slow compilation times are in UE5 (noticed that this post is tagged as such), then this other thread could be related:
It seems that when compiling in UE5, fewer processes are created and/or the cpu isn’t being used at full capacity. This becomes obvious when comparing compilation performance between UE4 and UE5. Not sure yet if this is affecting all users, and whether or not this is a known issue by Epic. Hoping for an official response like “we are aware of this issue and it will be fixed in 5.0.2” or something along those lines.