Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce Caching to the Command Executor (#2110)
* Introduce Caching to the Command Executor Every time we run a command we spawn a new child process, which is expensive. Commands may differ a lot based on the CWD, shell, and other factors. However, with many extensions relying on us, C# and C# DevKit for example, often make us call 'dotnet_executable_path --info' with the same settings. This is a lot of overhead which can be cached. We can't cache it for too long because if someone edits the system, the result of dotnet --info may change. But most of the calls to info etc happen at the launch of the window which is also where perf is more vital. We add a setting to disable the cache or make it extended longer. This pattern allows caching in the future. We rely on node-cache which is a reputable library and MIT license. For everything that we want to be cached, we send the TTL for that command to the executor via options.dotnetInstallToolCacheTtlMs. That is separated into a different commit. The easiest way to test this is to open our extension log and see that things get cached and that changes depending on the ttl setting. * Install node-cache * Fix package lock * Update Packages * Update Dependencies Again * Turn on cacheing for individual commands * Fix Lint * Call ABS on the Cache Value to protect from negative input * Fix whitespace so setting shows up * Fix bug where cache wouldnt get used * Cache more stuff! * Cache more! * Cache More Stuff * Fix Lint * Get the TTL before it's deleted. * Dont delete from the obj as that breaks Single Respon Principle * Cache the dotnet --info less as it appears to be too long * fix path lookup it could return all runtimes since the env wasnt set thus ignoring the setting * add save on format settings for the repo * add cache tests * Improve ? handling * Improve ? handling * Simplify Code Co-authored-by: Michael Yanni <[email protected]> * Simplify code. Co-authored-by: Michael Yanni <[email protected]> * Fix whitespace Co-authored-by: Michael Yanni <[email protected]> * Fix whitespace Co-authored-by: Michael Yanni <[email protected]> * Fix code style --------- Co-authored-by: Michael Yanni <[email protected]>
- Loading branch information