Skip to content

Restore local grain directory lookup fast path#10126

Merged
ReubenBond merged 1 commit into
dotnet:mainfrom
ReubenBond:grain-directory-local-fastpath
May 26, 2026
Merged

Restore local grain directory lookup fast path#10126
ReubenBond merged 1 commit into
dotnet:mainfrom
ReubenBond:grain-directory-local-fastpath

Conversation

@ReubenBond

@ReubenBond ReubenBond commented May 21, 2026

Copy link
Copy Markdown
Member

Reason

The grain directory metrics PR should stay focused on metric wiring and cleanup. The local lookup fast path restoration is a related but separate runtime behavior change, so it is split into this follow-up PR.

This PR is stacked on #10124. Until #10124 merges, GitHub may show the lower-stack metrics commits in the diff; the incremental change is the Restore local directory lookup fast path commit.

Solution

Restore a DHT fast path for cache-miss-heavy local-owner cases. The DHT locator now delegates its synchronous lookup path to the local grain directory, which checks the cache first and then, when this silo owns the grain's directory partition, reads the authoritative local partition before queueing placement work.

This keeps custom/pluggable grain directory behavior cache-only while allowing the built-in DHT directory to avoid unnecessary placement worker queuing for local partition hits.

Microsoft Reviewers: Open in CodeFlow

@ReubenBond ReubenBond force-pushed the grain-directory-local-fastpath branch from 268d984 to 8479e84 Compare May 21, 2026 17:45
@ReubenBond ReubenBond force-pushed the grain-directory-local-fastpath branch from 8479e84 to 9aa2e19 Compare May 21, 2026 20:36
@ReubenBond ReubenBond marked this pull request as ready for review May 21, 2026 20:43
@ReubenBond ReubenBond requested a review from Copilot May 21, 2026 20:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Restores a synchronous “local-owner” lookup fast path for the built-in DHT grain directory by letting the DHT locator consult the local directory’s authoritative partition on cache miss, avoiding unnecessary placement work queuing when this silo owns the directory partition.

Changes:

  • Added ILocalGrainDirectory.TryLocalLookup(...) and implemented it in LocalGrainDirectory to check cache first, then the authoritative local partition when this silo is the partition owner.
  • Updated DhtGrainLocator.TryLookupInCache(...) to delegate to the new local fast-path method.
  • Added a unit test validating that TryLocalLookup finds a local-partition entry after an explicit cache invalidation.
Show a summary per file
File Description
test/Orleans.Core.Tests/Directory/MockLocalGrainDirectory.cs Updates test mock to implement the new TryLocalLookup API.
test/Orleans.Core.Tests/Directory/CachedGrainLocatorTests.cs Adds coverage for LocalGrainDirectory.TryLocalLookup behavior on cache miss with local partition ownership.
src/Orleans.Runtime/GrainDirectory/LocalGrainDirectory.cs Implements the local-owner synchronous lookup fast path with appropriate metrics.
src/Orleans.Runtime/GrainDirectory/ILocalGrainDirectory.cs Adds TryLocalLookup to the local directory internal interface.
src/Orleans.Runtime/GrainDirectory/DhtGrainLocator.cs Routes synchronous lookup to TryLocalLookup to enable the restored fast path.
src/Orleans.Core/GrainDirectory/IGrainLocator.cs Clarifies TryLookupInCache contract/documentation as “no async work” (cache and/or authoritative local partition).

Copilot's findings

  • Files reviewed: 6/6 changed files
  • Comments generated: 0

Use the DHT local grain directory to resolve cache misses from this silo's authoritative directory partition before queueing placement work.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@ReubenBond ReubenBond force-pushed the grain-directory-local-fastpath branch from 9aa2e19 to b397730 Compare May 22, 2026 19:27
@ReubenBond ReubenBond added this pull request to the merge queue May 26, 2026
Merged via the queue into dotnet:main with commit a211431 May 26, 2026
62 checks passed
@ReubenBond ReubenBond deleted the grain-directory-local-fastpath branch May 26, 2026 16:45
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