Skip to content

Increase HTTP connection pool minimum to 64#1928

Open
tyrielv wants to merge 1 commit intomicrosoft:masterfrom
tyrielv:tyrielv/oom-connection-pool-size
Open

Increase HTTP connection pool minimum to 64#1928
tyrielv wants to merge 1 commit intomicrosoft:masterfrom
tyrielv:tyrielv/oom-connection-pool-size

Conversation

@tyrielv
Copy link
Copy Markdown
Contributor

@tyrielv tyrielv commented Mar 27, 2026

Problem

The connection pool was sized to Environment.ProcessorCount (e.g., 8 on an 8-core machine). HTTP object downloads are I/O-bound, not CPU-bound, so CPU count is a poor proxy for optimal concurrency. During burst workloads or with many external processes accessing files through ProjFS, smaller connection pools can quickly saturate.

Change

Sets a floor of 64 connections by default: Math.Max(Environment.ProcessorCount, MinConnectionLimit). No-op on machines with >64 cores.
Adds a configuration option to override

Key review areas

  • Interaction with the other OOM PRs (coalescing + circuit breaker reduce the need for large pools — is 64 still the right number?)

Testing

No new tests (static initialization). Full test suite (695 tests) passes.

@tyrielv tyrielv force-pushed the tyrielv/oom-connection-pool-size branch from 31d0a0b to 937c6e1 Compare March 27, 2026 23:23
@tyrielv tyrielv marked this pull request as ready for review March 27, 2026 23:55
@tyrielv tyrielv force-pushed the tyrielv/oom-connection-pool-size branch from 937c6e1 to 5e2e15c Compare March 31, 2026 17:48
Copy link
Copy Markdown

@KeithIsSleeping KeithIsSleeping left a comment

Choose a reason for hiding this comment

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

Review comment

Copy link
Copy Markdown

@KeithIsSleeping KeithIsSleeping left a comment

Choose a reason for hiding this comment

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

Review comment

Copy link
Copy Markdown

@KeithIsSleeping KeithIsSleeping left a comment

Choose a reason for hiding this comment

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

Review comment

Copy link
Copy Markdown

@KeithIsSleeping KeithIsSleeping left a comment

Choose a reason for hiding this comment

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

Review comment

Copy link
Copy Markdown
Member

@mjcheetham mjcheetham left a comment

Choose a reason for hiding this comment

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

64 feels way too high and we run a risk of exhausting ports especially on a machine with multiple enlistments mounted simultaneously.

One thought, do we want to move to a 'lease and return' pool model? (There's a generic ObjectPool we could leverage already.)

Pools like this maintain a set of resources, but when a request for another comes in when all existing resources are 'loaned out' then the pool will mint a new resource, or grow the pool - do we want to look at a dynamic pool size?

Shrinking back to the default again after some period of being below the threshold, or when enough resources are returned. Obviously this is a bigger change than just up-ing a semaphore's static limit.

The connection pool was previously sized to Environment.ProcessorCount (e.g., 8
on an 8-core machine). HTTP object downloads are I/O-bound, not CPU-bound, so
CPU count is a poor proxy for optimal connection concurrency. Under burst
workloads like git checkout, connections saturate almost instantly.

Set the default to 2x ProcessorCount. This provides more headroom during burst
object download scenarios without being overly aggressive for machines with
multiple mounts.

The pool size can be overridden via git config:

    git config gvfs.max-http-connections <value>

Any positive integer is accepted. The semaphore is adjusted in-place (via
Release/Wait) rather than replaced, so in-flight requests always release
permits to the correct instance.

Work item: 60167591

Assisted-by: Claude Opus 4.6
Signed-off-by: Tyrie Vella <tyrielv@gmail.com>
@tyrielv tyrielv force-pushed the tyrielv/oom-connection-pool-size branch from 5e2e15c to 43ff0ed Compare April 2, 2026 14:47
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.

3 participants