-
-
Notifications
You must be signed in to change notification settings - Fork 392
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improved compile speed by running multi-threaded library discovery. #2625
base: master
Are you sure you want to change the base?
Conversation
f408819
to
05c4745
Compare
05c4745
to
8afa7d8
Compare
LGTM |
55ee2f5
to
cc15358
Compare
cc15358
to
87765a4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From my POV, is okay. I tested it on some sketches and I can see the improvement.
However, let's wait for some other users to gather feedback. (Just in case some edge cases arise).
This change is preparatory for next refactorings
This equivalent change moves the 'first' variable closer to his definition and use.
There is no need to duplicate the preprocessResult/Err variables. This also simplifies naming making it more straighforward.
Also fixed the "low memory" warning printer.
The new release of the library allow ignoring the returned error. arduino/go-properties-orderedmap#42
It slightly simplifies code, but also provide the basis for the next commits.
87765a4
to
9536817
Compare
Hi, I'm using Arduino IDE 2.x everyday on my open-source ReflectionsOS project. It's an ESP32-S3 board with a bunch of sensors. About 18,000 lines of code so far. Compiles on my MacBook Air M2 2022 8 Cores takes about 3-4 minutes. I'd be glad to spend time and money testing the PR. Would someone please give me instructions on how to get the PR code and compile the IDE for Mac? -Frank |
Please check if the PR fulfills these requirements
See how to contribute
before creating one)
our contributing guidelines
UPGRADING.md
has been updated with a migration guide (for breaking changes)configuration.schema.json
updated if new parameters are added.What kind of change does this PR introduce?
This is a tentative to improve compile speed by multi-threading the library discovery phase.
How library discovery works
The library discovery is a sequential process, and could be summarized as follows:
gcc -E ...
)Missing include file "xxx.h"
error then:xxx.h
is added to the includes path listThe above loop continues until one of the following happens:
missing include
Could this be multi-threaded?
The main issue here is that each run of
gcc -E ...
requires the includes path list determined by the previous iterations. At first sight, it seems a strictly sequential process.BTW, there are some strategies that we may use:
When a library is added to the queue, we may speculatively start a multithreaded compilation of the next files in the queue assuming no
missing include
errors will be produced. Most of the time this assumption turns out to be true and the time saved could be dramatic.We may leverage the "library detection cache" to spawn a speculative multithreaded compilation of all the files (predicting all the libraries added in the process), assuming that the
missing include
errors would be the same as the previous successful compilation as saved in the "library detection cache". In this case, we reproduce the same compiles as the previous build. The basic assumption is that the libraries detected will not change between compilations.If an unforeseen
missing include
error is detected, the speculative multithreaded compilation must be canceled and restarted (basically wasting the work done ahead of time). In a multi-core system, since the work "ahead" is done in parallel, the worst-case scenario should take nearly the same time as the "classic" non-multithreaded compile.Due to the complexity of these changes, I'll start this as a draft. I want to add integration tests to trigger edge cases before merging.
What is the current behavior?
What is the new behavior?
Compiles should in general be faster than before.
Does this PR introduce a breaking change, and is titled accordingly?
No
Other information