Skip to content

Mitigate packaged preindexed source open lock convoy#6172

Merged
JohnMcPMS merged 2 commits into
microsoft:masterfrom
mamoreau-devolutions:fix-preindexed-source-lock-performance-issue
Apr 23, 2026
Merged

Mitigate packaged preindexed source open lock convoy#6172
JohnMcPMS merged 2 commits into
microsoft:masterfrom
mamoreau-devolutions:fix-preindexed-source-lock-performance-issue

Conversation

@mamoreau-devolutions
Copy link
Copy Markdown
Contributor

@mamoreau-devolutions mamoreau-devolutions commented Apr 22, 2026


Related issue

Closes #6167

Summary

This change narrows the lock scope for packaged preindexed source opens.

Previously, opening a packaged preindexed source always acquired the named cross-process lock before doing the read-only open work. Under concurrent winget usage, that serialized source reads behind unrelated activity and caused large stalls before commands like show or search could do meaningful work.

This PR changes the packaged-context open path to:

  • attempt the packaged source open optimistically first
  • reuse a helper for extension lookup, content integrity verification, and immutable SQLite open
  • fall back to the existing cross-process lock only if the optimistic open fails
  • preserve cancellation behavior
  • add timing/logging around the open path to make the mode and cost visible

The change is limited to PreIndexedPackageSourceFactory.cpp.

Testing

Manual validation against the issue repro:

  • compared behavior against concurrent packaged source reads
  • verified the fallback path still retries under the existing lock when optimistic open fails

Static validation:

  • no diagnostics reported for the touched file
Microsoft Reviewers: Open in CodeFlow

Use an optimistic packaged source open and retry under the existing mutex only if the unlocked read hits a transient race.\n\nCo-authored-by: Copilot <[email protected]>
@mamoreau-devolutions mamoreau-devolutions requested a review from a team as a code owner April 22, 2026 20:10
Comment thread src/AppInstallerRepositoryCore/Microsoft/PreIndexedPackageSourceFactory.cpp Outdated
Comment thread src/AppInstallerRepositoryCore/Microsoft/PreIndexedPackageSourceFactory.cpp Outdated
Comment thread src/AppInstallerRepositoryCore/Microsoft/PreIndexedPackageSourceFactory.cpp Outdated
@JohnMcPMS
Copy link
Copy Markdown
Member

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@JohnMcPMS JohnMcPMS merged commit 501c0b7 into microsoft:master Apr 23, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Packaged preindexed source read opens are serialized behind an exclusive mutex under concurrent winget usage

2 participants