Repository navigation
[Fusion] Batch path segment pool access and keep the local pool across requests - #10548
Merged
Merged
Conversation
tobias-tengler
force-pushed
the
tte/fusion-lock-hotspots
branch
from
October 15, 2026 13:19
5096a90 to
e6c92b7
Compare
Contributor
Patch coverage98.3% of changed lines covered (174/177)
Uncovered changed lines (JSON){
"sha": "f63946282819db97eee5a86f68c594e7f818a02f",
"files": [
{ "path": "src/HotChocolate/Fusion/src/Fusion.Execution/Text/Json/PathSegmentPool.cs", "ranges": [[124, 126]] }
]
}Project coverage: 59.0% (310997/527501 lines) |
tobias-tengler
force-pushed
the
tte/fusion-lock-hotspots
branch
from
October 15, 2026 16:02
648a1f7 to
2a163cf
Compare
…s requests The shared path segment pool hands out and takes back arrays in batches of 32, and the request-local pool stays alive in the pooled FetchResultStore, keeping up to the configured capacity of arrays between requests. The local pool shrinks its bookkeeping after a burst and drops its arrays when the shared pool is replaced, and the shared pool checks array lengths and keeps its in-use count balanced. A result document allocates its paths once its pool has been reset for the next request.
tobias-tengler
force-pushed
the
tte/fusion-lock-hotspots
branch
from
October 15, 2026 17:10
1482252 to
74ff48d
Compare
tobias-tengler
marked this pull request as ready for review
October 15, 2026 17:15
…d pool lock holds The local path segment pool now drops returns once every owned array is free, so a straggling return after a reset cannot put a duplicate into the free list, and renting from a disposed pool throws instead of leaking. The shared pool rents and returns in chunks of 32 per lock acquisition, so a large request teardown no longer holds the spin lock for its whole span, and the return logging skips null entries. Result documents are detached from the request scoped pool when the store hands its memory owners to the operation result, which replaces the generation guard.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Every result path borrows an
int[]from the process-widePathSegmentPool, and every rent and return takes itsSpinLock. A request with nested lookups needs hundreds to thousands of paths, so with a few busy cores the threads spin on that lock, andOperationPlanContext.Cleanreturns every array through it once more.The shared pool now rents and returns arrays in batches of 32, and the request-local pool stays alive in the pooled
FetchResultStore: after a request it marks its arrays free again and returns only what exceedsPathSegmentLocalPoolCapacity(64 by default, 1 the minimum). A request touches the shared lock a few times instead of twice per path. The local pool shrinks its bookkeeping after a burst and drops its arrays when the shared pool has been replaced; the shared pool rejects arrays of another length without unbalancing its in-use count. A result document is detached from the local pool when the store hands its memory to the operation result, so a path read after execution is allocated and never touches another request's arrays. The local pool drops returns once every owned array is free, so a straggling return after a reset cannot hand the same array to two paths, and the shared pool holds its lock for at most 32 arrays per rent or return.Benchmarks
Each thread is one pooled request context with its own local pool, running requests back to back. A request rents the given number of paths, returns half and ends. Mean is the time per request on one thread.
Path segments, 1 thread, 32 paths per request
mainPath segments, 1 thread, 1024 paths per request
mainPath segments, 4 threads, 32 paths per request
mainPath segments, 4 threads, 1024 paths per request
mainPath segments, 16 threads, 32 paths per request
mainPath segments, 16 threads, 1024 paths per request
main