If so, does that mean we should review and remove libraries that may no longer be needed? Would that improve compile time performance (after a restart of the IDE)?
If the preprocessing failed with a "No such file or directory" error for an #include directive, search all the installed libraries for a file of that name.
So the number of installed libraries impacts the duration of step 2. However, it will not affect the duration of any of the other steps. I would guess that in most cases step 1 is where most of the time is spent.
I have experienced this extended upload time as well, though it was mainly during a time when i was not online during compilation, but yes quite extreme.
What did you change. I found that once i have a complete compilation including all libraries and without error, compilation was reduced to 2 minutes (my laptop is quite quick)
But initially it was insanely slow when including a new library (version)
If I am remembering correctly, if his code is broken up into several ino files then a change to one causes all of them to be collected and recompiled. I am wondering though what happens if the .cpp/.h model is used, are the other source files that were not changed re-compiled in that case?
No. The cached object from the previous compilation will be used for .cpp and .c files of a sketch which have not been modified since the previous compilation for that board.
But still a compilation time of 20 minutes seems excessive. Usually it is not the .ino files that are taking that much time to compile anyway, but the included libraries. The cached version appears not to be stored until at least 1 completely successful compilation, regardless of where the error may be (which makes sense you can hardly expect the compiler to figure out where the error actually is)
Although it does have some features that rely on Internet communication (e.g., Library Manager), Arduino IDE does not use the "cloud" in any way as a part of the compilation process.
Some antivirus programs/configurations result in the antivirus performing a "real time scan" on each new process. Arduino IDE generates a significant number of short processes when compiling the sketch, as is needed to run the various compiler tools. If each of those processes is blocked by the antivirus until after it has completed a scan, this could significant increase the duration of the compilation.
Although even just a significant amount of local processing time for the scan could impact the compilation duration, it is also possible that Internet communication could be part of the antivirus program's scanning procedure. In this way, restrictions or problems with network and Internet communication could indirectly impact the performance of Arduino IDE.
It is also possible that restrictions or problems with the network could directly affect Arduino IDE's compilation process. The Arduino IDE application itself mostly only implements the GUI components. The actual compilation process is orchestrated by a helper tool named Arduino CLI. Communication between the Arduino IDE "frontend" and this helper tool is done via the computer's internal network ("localhost"). For this reason, although the Internet is not involved in any way, if something like a firewall impacts communication via the internal network, then it will impact Arduino IDE's performance.
Well i am using F-Secure, and i have a tendency to perform a full-computer scan when something is not working on my computer as expected.
Recently my desktop was shutting down and starting up properly but a restart was causing a crash. In the end it turned out to be the external soundcard that had to be powered off, but when i performed the scan, a file from the ESP32 core showed up as a (probably false) positive for a trojan. I reported it as a false positive to F-Secure and i haven't heard from them since, so it most likely was, but there is always the possibility for core tools & files to do things that were not intended to be done by the IDE.
Real-time scanning probably would impact the performance, but usually an anti-virus program does not start to contact it's knowledge base during that. Also i am quite sure i disabled the anti-virus, since i was anyway offline, during these long compiles.