dotnet / dotnet/vscode-dotnet-runtime

Reduce process count by implementing muxer validation ourselves

Open
#2,694 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
209
Forks
455
PR merge metrics
No merged PRs in 30d

Description

# Context
We validate each runtime version upon install using `dotnet --list-runtimes`. But the only validation that the muxer does:

(for runtimes)

a. checks that .deps.json exists in /shared/,
b. as well as valid semver as the folder version
https://github.com/dotnet/runtime/blob/cecdae61d396bf390ff6e2e5378dc2f804fb8606/src/native/corehost/fxr/framework_info.cpp#L79

c. blocks any runtime folder based on the version directory name, to respect 'DOTNET_DISABLE_RUNTIME_VERSIONS' https://github.com/dotnet/runtime/blob/cecdae61d396bf390ff6e2e5378dc2f804fb8606/src/native/corehost/fxr/framework_info.cpp#L98
d. the architecture is a match

(for sdks)

a. that the dotnet.dll exists:
https://github.com/dotnet/runtime/blob/b79d4c48d3eec6dcf21a0d71eb2aabda7cdaa95d/src/native/corehost/fxr/sdk_info.cpp#L64
b. that it is a valid semver folder
c. global.json/cwd influenced in terms of what dotnet root it looks into https://github.com/dotnet/runtime/blob/b79d4c48d3eec6dcf21a0d71eb2aabda7cdaa95d/src/native/corehost/fxr/sdk_resolver.cpp#L77-L100

# Suggestion

The SDK lookup with global.json / CWD is harder to mirror and more likely to break / change, so I would suggest starting with just the runtimes.

# Wins

Instead of spawning a process and calling this to validate, our logic mostly does this already today, we can incorporate the few caveats.
This is less future-proofed if the muxer changes, but it rarely does and this is worth a perf win, reducing at least:

Startup:
1 process when acquire is called to validate the runtime, OR 1 process if acquire is not needed but we validate the existing install before returning it. (Essentially true every time)
Up to 5 processes per find-path call when it validates the path, depending on if there are 5 unique dotnet installs (unlikely - usually it is only 1 to 2.)

Post Startup:
N processes for N (total installed) runtimes during the automatic updater when it validates each runtime

In the future:
N processes for N runtimes during findPath call if we ever re-add local runtime to the path search, which we can now do

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.