Skip to content

Allow for better parallelization with brokered services#82733

Open
jasonmalinowski wants to merge 1 commit intodotnet:mainfrom
jasonmalinowski:allow-better-parallelization
Open

Allow for better parallelization with brokered services#82733
jasonmalinowski wants to merge 1 commit intodotnet:mainfrom
jasonmalinowski:allow-better-parallelization

Conversation

@jasonmalinowski
Copy link
Copy Markdown
Member

@jasonmalinowski jasonmalinowski commented Mar 12, 2026

By default, there is a SynchronizationContext set that ensures that when dispatching new RPC requests, a new RPC requests is not dispatched until the previous request either finishes, or awaits to yield the thread. Although there are some cases where we do need behavior like that (LSP is the perfect example), we don't need that for brokered services.

By default, there is a SynchronziationContext set that ensures that
when dispatching new RPC requests, a new RPC requests is not dispatched
until the previous request either finishes, or awaits to yield the
thread. Although there are some cases where we do need behavior like
that (LSP is the perfect example), we don't need that for brokered
services.
@jasonmalinowski jasonmalinowski self-assigned this Mar 12, 2026
@jasonmalinowski jasonmalinowski requested a review from a team as a code owner March 12, 2026 21:56
// The default synchronization context set by the base type is NonConcurrentSynchronizationContext, which means that all incoming calls
// would be processed sequentially, at least up until their first await. We generally don't have services that expect ordering in that specific way, so
// disable that, especially since we want CPU-bound operations to happen in parallel.
jsonRpc.SynchronizationContext = null;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does this apply to all brokered service usages - or just devenv -> oop? (e.g. does this apply to vscode brokered services)

Copy link
Copy Markdown
Member Author

@jasonmalinowski jasonmalinowski Mar 12, 2026

Choose a reason for hiding this comment

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

@dibarbet As best I know, everything, VS Code included.

@dotnet dotnet deleted a comment from github-actions bot Mar 19, 2026
@dotnet dotnet deleted a comment from github-actions bot Mar 20, 2026
@dotnet dotnet deleted a comment from github-actions bot Mar 23, 2026
@jasonmalinowski
Copy link
Copy Markdown
Member Author

/pr-val

@github-actions
Copy link
Copy Markdown
Contributor

View PR Validation Run triggered by @jasonmalinowski

Parameters
  • Validation Type: pr-val
  • Pipeline ID: 8972
  • Pipeline Version: main
  • PR Number: 82733
  • Commit SHA: 5e89729f0a5bedf81053392a6e9a4f0e0f4cb075
  • Source Branch: allow-better-parallelization
  • Target Branch: main
  • Build ID: 13630159

@jasonmalinowski
Copy link
Copy Markdown
Member Author

The internal validation build is showing allocation regressions in RemoteHostAssetWriter.WriteBatchToPipeAsync. I have two theories for this:

  1. This is implicitly breaking some sort of timing we were relying on for efficient OOP sync.
  2. By making things faster, the allocations are now happening sooner. The burst of allocations are tending to be towards the end of the test run, so it's possible that without this change we were simply not getting "far enough" in the test scenario to start syncing stuff to OOP, but now we're doing that faster

I've kicked off an internal build to test the second theory by just adding a bit wait at the end of the test.

@jasonmalinowski
Copy link
Copy Markdown
Member Author

With @kayle's help I got a run with an extra wait at the end. Although I see more work being done, I don't see more work through the RemoteHostAssetWriter, which points towards option 1 being the problem here.

@drewnoakes
Copy link
Copy Markdown
Member

@jasonmalinowski do you have any theories about this?

@jasonmalinowski
Copy link
Copy Markdown
Member Author

@drewnoakes Nothing better than what I've posted. My attention has been elsewhere for the last few days.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants