Skip to content

Replace process spawn with IPC for hydration status in hooks#1919

Merged
tyrielv merged 1 commit intomicrosoft:masterfrom
tyrielv:tyrielv/hydration-status-5-ipc
Mar 24, 2026
Merged

Replace process spawn with IPC for hydration status in hooks#1919
tyrielv merged 1 commit intomicrosoft:masterfrom
tyrielv:tyrielv/hydration-status-5-ipc

Conversation

@tyrielv
Copy link
Contributor

@tyrielv tyrielv commented Mar 23, 2026

Replace process spawn with IPC for hydration status in hooks

The pre-command hook previously spawned gvfs.exe health --status on every git status, adding ~200ms+ of process creation overhead. This replaces that with a named pipe query to the mount process, which returns the cached hydration summary in <10ms.

The mount process already computes the hydration summary in GitStatusCache on each rebuild cycle. This PR caches that result and serves it over IPC, so the hook just reads the cached value instead of recomputing it.

Changes

File Change
HydrationStatusNamedPipeMessages.cs New file — HydrationStatus.Request, Response with TryParse/ToBody/ToDisplayMessage; integer overflow fix in percentage calc
Program.cs (Hooks) Replace ProcessHelper.Run("gvfs health --status") with TryDisplayCachedHydrationStatus() — named pipe query with 50ms connect + 100ms outer timeout; remove circuit breaker check (mount handles it)
InProcessMount.cs IPC handler for HydrationStatus.Request — returns cached summary or NotAvailableResult with telemetry
GitStatusCache.cs Cache valid EnlistmentHydrationSummary in volatile field; expose via GetCachedHydrationSummary(); RecordFailure() on unexpected exceptions
FileSystemCallbacks.cs Bridge GetCachedHydrationSummary() to GitStatusCache
HealthVerb.cs Try IPC first (TryGetCachedHydrationMessage), fall back to in-proc computation
EnlistmentHydrationSummary.cs Split HydratedFileCount/FolderCount into Placeholder + Modified components for granular IPC response; fix integer overflow
GVFS.Hooks.csproj Add HydrationStatusNamedPipeMessages.cs file-link; remove HydrationStatusCircuitBreaker.cs file-link
HydrationStatusErrorPathTests.cs New — TryParse error paths, ToBody round-trip, ToDisplayMessage formatting

@tyrielv tyrielv force-pushed the tyrielv/hydration-status-5-ipc branch from ff7a1d1 to a3f5750 Compare March 23, 2026 23:04
@tyrielv tyrielv enabled auto-merge March 23, 2026 23:08
Copy link

@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.

Multi-Model Code Review

Reviewed with Claude Opus 4.6, GPT-5.1-Codex-Max, and GPT-5.4. Findings below are consensus items where multiple models independently identified the same issue.

Replace gvfs.exe process spawn with named pipe IPC for hydration status
display in git status pre-command hook.

- Rename LockNamedPipeMessages to SharedNamedPipeMessages, add HydrationStatus
  message types with structured response (split Placeholder/Modified counts)
- Hook queries mount process via named pipe with 100ms Task.Run bound
- InProcessMount handles hydration status IPC requests
- GitStatusCache caches EnlistmentHydrationSummary, exposed via IPC
- HealthVerb tries IPC cache first, falls back to in-proc computation
- Split HydratedFileCount/FolderCount into Placeholder + Modified components
- Record circuit breaker failure on unexpected exceptions
- Add HydrationStatusErrorPathTests (IPC parsing, cancellation, edge cases)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@tyrielv tyrielv force-pushed the tyrielv/hydration-status-5-ipc branch from a3f5750 to a1ba896 Compare March 24, 2026 17:27
Copy link

@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.

All feedback addressed: HealthVerb now has Task.Wait timeout (500ms connect + 1s total), cachedHydrationSummary cleared on invalidation/error/shutdown. LGTM.

@tyrielv tyrielv merged commit 64dc7b2 into microsoft:master Mar 24, 2026
49 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.

2 participants