Skip to content

Conversation

@elinor-fung
Copy link
Member

@elinor-fung elinor-fung commented Jan 23, 2026

The presence of a servicing directory (even empty) would enable file existence checks for all files in the deps.json. We always look in the servicing directory first (if it exists) - and only care about the file existence there, not in the regular app directory. This change limits file existence checks to only when probing the servicing directory itself.

This reduces I/O operations during startup for applications that have a servicing directory present (and don't use additional probe paths or shared stores).

For the staticconsoletemplate startup test in dotnet/performance, running locally on Windows, if an empty servicing directory exists:

Metric Before After Delta
Average 69.812 ms 58.895 ms -10.92 ms (-15.6%)
Min 69.392 ms 58.467 ms -10.93 ms
Max 70.772 ms 59.327 ms -11.45 ms
Std Dev 0.393 ms 0.290 ms -0.10 ms (26% tighter)
Range 1.38 ms 0.86 ms 38% smaller

@dotnet/appmodel @AaronRobinsonMSFT

Previously, the presence of a servicing directory would enable file
existence checks for all probed files (app, framework, lookup, and
servicing directories). This change limits file existence checks to
only when probing the servicing directory itself.

This reduces I/O operations during startup for applications that have
a servicing directory present but don't use additional probe paths or
shared stores.
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @agocke, @jeffschwMSFT, @elinor-fung
See info in area-owners.md if you want to be subscribed.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Reduces hostpolicy startup I/O when a servicing directory exists by limiting file existence checks to servicing probes instead of enabling them globally.

Changes:

  • Stop setting the global m_needs_file_existence_checks flag solely due to the presence of the servicing directory.
  • When probing a servicing config, explicitly enable is_servicing + file_existence search options for that probe only.

if (entry.to_library_package_path(config.probe_dir, candidate, search_options | (config.is_servicing() ? deps_entry_t::search_options::is_servicing : 0)))
if (config.is_servicing())
{
search_options |= deps_entry_t::search_options::is_servicing | deps_entry_t::search_options::file_existence;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the file_existence flag needed now? Was it added elsewhere previously?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is also added if additional probe paths or a shared store is specified (m_needs_file_existence_check). In those cases, it is added for all probe configs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So what you're saying is setting m_needs_file_existence_checks to true sets the file_existence flag and we could technically assert the old code that that flag was set? If so, does is_servicing imply file_existence?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setting m_needs_file_existence_checks to true sets the file_existence flag

Yes. We initialize search_options based on m_needs_file_existence_checks.

we could technically assert the old code that that flag was set

Do you mean assert that m_needs_file_existence_checks is the same as whether search_options has the file_existence flag? Then yes. But it is initialized exactly to a couple lines above in the same function, so I don't know that it would be useful.

does is_servicing imply file_existence?

Yes. I do think is_servicing could go away - it doesn't seem so much a search option as just added in there specifically for a single-file scenario, which I think we could do differently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants