Skip to content

Reduce process count by implementing muxer validation ourselves #2694

@nagilson

Description

@nagilson

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions