graphics: optimize getNvidiaSmi()#927
Conversation
narrows down candidate directories smarter, uses stat to check for file existence instead of listing all files in the directory and then checking inside that array, and also avoids calling stat for the same file multiple times.
lib/graphics.js
Outdated
| }); | ||
| let newestNvidiaSmi = null; | ||
| for (const dir of fs.readdirSync(basePath)) { | ||
| // nvidia-smi will only be located in directories starting with `nvdm`. |
There was a problem hiding this comment.
this may or may not be true. we may want to broaden this to just look inside all directories that start with nv (case insensitive.)
|
Heloo jhgg, Thanks for letting my borrow you lamborghini that one day. |
|
at least on my system, |
from my understanding that's a legacy path. can you check the creation time? |
|
11/07/2024, last time i updated my drivers |
Mine is also located in Created: July 21, 2024 So I am assuming I installed the driver on the 21st, and it was released on the 11th |
|
When a driver is installed, it gets staged into the driver store, and then most of its files get a corresponding symlink in There is absolutely no need to scan the driver store. |
|
We can be sure nvidia-smi.exe always gets symlinked, because, when looking at a driver's INF file, we can find the following: And every section in the driver INF has a CopyFile directive for that: It's not legacy, as they do not implement the corresponding state for Run From Driver Store |


narrows down candidate directories smarter, uses stat to check for file existence instead of listing all files in the directory and then checking inside that array, and also avoids calling stat for the same file multiple times.