Skip to content
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

Option for RAM Caching dependencies #2210

Open
3 tasks done
marcusobrien opened this issue Jun 12, 2023 · 1 comment
Open
3 tasks done

Option for RAM Caching dependencies #2210

marcusobrien opened this issue Jun 12, 2023 · 1 comment
Labels
topic: build-process Related to the sketch build process topic: code Related to content of the project itself type: enhancement Proposed improvement

Comments

@marcusobrien
Copy link

Describe the request

Compile times take too long.
IDe designers dont want to stop the auto dependency discovery that the IDE currently does, to keeps things easy for novice users.
Users want fasterer compile times.

Reading posts on here,

#1996

sounds like long build times is the scanning of libs for dependencies - and this involves disk access.
Can we have a mode called auto cache - that simply caches in RAM (so only for this session) on first compile, all the dependencies for the sketch - then no disk access needed for subsequent compiles/links.

Or what about a GreedyCacheMode, that when enabled reads into memory ALL arduino libs in paths, and use those to resolve/compile/link the binary. This would be much faster than scanning folders and files etc. Most people have a lot of RAM nowdays, so let the user choose how to make use of their own ram.

Describe the current behavior

Build scans for libraries and dependencies as their are no linker arguments provided by the user. This results in slow compile times for large projects with many headers, and external symbols etc (linker)

Arduino CLI version

2.1.0

Operating system

Windows

Operating system version

10

Additional context

No response

Issue checklist

  • I searched for previous requests in the issue tracker
  • I verified the feature was still missing when using the nightly build
  • My request contains all necessary details
@marcusobrien marcusobrien added the type: enhancement Proposed improvement label Jun 12, 2023
@per1234 per1234 added the topic: code Related to content of the project itself label Jun 12, 2023
@cmaglie cmaglie added the topic: build-process Related to the sketch build process label Sep 1, 2023
@PaulStoffregen
Copy link
Sponsor

PaulStoffregen commented Jan 17, 2024

what about a GreedyCacheMode, that when enabled reads into memory ALL arduino libs in paths, and use those to resolve/compile/link the binary

Today if you edit any library or header file, Arduino CLI notices the file's modification time is newer and rebuilds the file. In the case of headers, all files which include the header you've edited get rebuilt. Assuming this behavior would be maintained, even if a copy of all those files were held in RAM, the modification time on every file would still need to be checked to decide which files actually need to be recompiled.

Sadly, simply checking a file's metadata is slow on Windows. This message explains the reason why Windows file metadata is so slow. If you try Linux with a lot of RAM (for the kernel to cache filesystem metadata), you'll see quite a performance difference. Even if you have infinite RAM, Windows can't use it to cache filesystem metadata because of the way Microsoft designed their system.

Arduino CLI does cache dependency info already. You can see it with verbose mode. For example, compile a program twice and on the 2nd run you'll see it's using cached results.

Using cached library dependencies for file: /home/paul/Arduino/libraries/Adafruit_GFX_Library/Adafruit_GFX.cpp
Using cached library dependencies for file: /home/paul/Arduino/libraries/Adafruit_GFX_Library/Adafruit_GrayOLED.cpp
Using cached library dependencies for file: /home/paul/Arduino/libraries/Adafruit_GFX_Library/Adafruit_SPITFT.cpp
Using cached library dependencies for file: /home/paul/Arduino/libraries/Adafruit_GFX_Library/glcdfont.c
Using cached library dependencies for file: /home/paul/Arduino/libraries/Adafruit_BusIO/Adafruit_BusIO_Register.cpp
Using cached library dependencies for file: /home/paul/Arduino/libraries/Adafruit_BusIO/Adafruit_I2CDevice.cpp
Using cached library dependencies for file: /home/paul/Arduino/libraries/Adafruit_BusIO/Adafruit_SPIDevice.cpp

The problem is even though the cached data can be used to avoid the work of recompiling, to check whether the cached data is fresh requires reading the modification time of every header file each includes. Just fetching the metadata is expensive on Windows.

However, perhaps the speed could be increased somewhat if Arduino CLI cached the filesystem modification times for headers. Then if you have many library files that include the same headers, it would only have to ask Windows for the modification time of each unique header only once.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: build-process Related to the sketch build process topic: code Related to content of the project itself type: enhancement Proposed improvement
Projects
None yet
Development

No branches or pull requests

4 participants