I am using the Arduino IDE 2.3.4 on Windows 11, on a Lenovo laptop with 11th Gen i71165G7 @ 2.80GHz, with 24GB of RAM
Code for the ESP32 Dev takes extremely long to compile. The bigger the project the longer it takes but even smallish test projects can easily take 30 to 60 minutes and on my actual project currently in progress it can easily take 2 hours!
Similar sized projects for Arduino boards compile in a fraction of the time.
Why is this so bad compiling for ESP32 based projects?
Maybe this is a return of an early bug that the IDE 2.X had.
Anyway without more details about your computer-configuration like
are you compiling code stored on a cloud-drive?
ist your IDE installation on a cloud-drive?
what anti-virus-software are you using?
The real expert for this is @ptillisch
I think he can give you the keywords to what you should looking at.
In the meantime give a portable installation of the Arduino-IDE 1.8.19 with ESP32-core version 2.0.17 a try
depending on your source-code it might be nescessary to update the core to version 3.X
Question is if IDE 2.3.4 behaves worse than the previous version of the IDE? And what the previous version of the IDE is?
Have you ever looked at the verbose compile output? The ESP32 core consists of hundreds or thousands of files. The IDE checks #included files (Arduino.h as the starting points) as well as all your included libraries) to see if they need to be compiled / compiled again. That process takes long. File a.h#includesb.h and c.h, b.h#includesc.h and z.h etc.
The more files there are, the more work. But 60 minutes is extremely long. An clean compile of an empty ESP32 sketch takes approx 20 seconds on my 12th gen i3 with 16 GB and SSD ( operating system Win11 home); for a 328P roughly 4 seconds. Second compile of the same sketch takes approx 9 second and 2 seconds respectively.
Can you please post a sketch that takes extremely long; please provide details of any 3rd party libraries that you use (how to install). Can you also please post the verbose compile output (you might have to attach it as a text file).
and then compile your sketch directly to time it. (You need the Fully Qualified Board Name, which is the first line in the verbose compile log; and point it at your sketch directory.)
PS E:\> Measure-Command {
& '~\AppData\Local\Programs\Arduino IDE\resources\app\lib\backend\resources\arduino-cli.exe' `
compile -v --clean -b "esp32:esp32:esp32" E:\Sketchbook\empty `
| Out-Default }
FQBN: esp32:esp32:esp32
... a bunch of build output
... and the total time
TotalSeconds : 23.8394734
TotalMilliseconds : 23839.4734
On my low-end quad-core, a clean compile of an empty sketch for ESP32 is also about 20 seconds.
With Measure-Command or time on Linux/Mac, you can let it run to completion over lunch or whatever. That has diagnostic value and satisfies morbid curiosity.
If you watch the verbose output, once it "gets going", each individual compiler command should take at most a second or so (and bursts where a bunch of them happen in rapid succession). You're seeing overall times over an order of magnitude longer; does it seem consistently that slow, or is there a big stall at some point(s)?