Repository navigation
Configurable concurrent resolution of subscription items - #2
Merged
amnn merged 1 commit intoJul 31, 2026
Conversation
tpham-mysten
force-pushed
the
tpham-mysten/buffered-subscription-resolution
branch
from
July 21, 2026 15:36
c54816b to
292035e
Compare
1 of 8 tasks
tpham-mysten
force-pushed
the
tpham-mysten/buffered-subscription-resolution
branch
from
July 27, 2026 15:34
292035e to
2a4ecc5
Compare
tpham-mysten
force-pushed
the
tpham-mysten/buffered-subscription-resolution
branch
4 times, most recently
from
July 27, 2026 16:35
b5cb9ea to
f5d40c3
Compare
tpham-mysten
marked this pull request as ready for review
July 28, 2026 16:54
amnn
self-requested a review
July 28, 2026 17:04
tpham-mysten
added a commit
to MystenLabs/sui
that referenced
this pull request
Jul 31, 2026
…rent resolution Flip the transaction subscription schema from the batched `[TransactionEdge!]!` to `TransactionEdge!` (one edge per payload, like checkpoint/event), and resolve payloads concurrently via async-graphql's `buffered` (SubscriptionConfig.max_concurrent_resolutions, default 100) so the per-payload KvLoader content reads coalesce instead of one round trip per transaction. Backfill scans through the shared `scan_grpc` with cvat=None (uniform with live, no consistent reads); the scan page is derived from the resolve concurrency so one scan feeds roughly one resolution window. Depends on amnn/async-graphql#2 for the `buffered` support; the `[patch]` points at that PR branch until it merges into amnn's branch. Add e2e reliability tests: live gap recovery, high-volume concurrent exactly-once + ordering, KvLoader read coalescing under concurrency, and invalid-cursor error surfacing. Add a serial-vs-concurrent backfill benchmark (200 txs: 401 round trips / 1.0s serial vs 5 round trips / 79ms concurrent) plus a manual server harness.
tpham-mysten
added a commit
to MystenLabs/sui
that referenced
this pull request
Jul 31, 2026
The buffered subscription support lives on a fork branch; restore the amnn base for a mergeable manifest. Build is red until amnn/async-graphql#2 lands and the lock is bumped.
tpham-mysten
added a commit
to MystenLabs/sui
that referenced
this pull request
Jul 31, 2026
…rent resolution Flip the transaction subscription schema from the batched `[TransactionEdge!]!` to `TransactionEdge!` (one edge per payload, like checkpoint/event), and resolve payloads concurrently via async-graphql's `buffered` (SubscriptionConfig.max_concurrent_resolutions, default 100) so the per-payload KvLoader content reads coalesce instead of one round trip per transaction. Backfill scans through the shared `scan_grpc` with cvat=None (uniform with live, no consistent reads); the scan page is derived from the resolve concurrency so one scan feeds roughly one resolution window. Depends on amnn/async-graphql#2 for the `buffered` support; the `[patch]` points at that PR branch until it merges into amnn's branch. Add e2e reliability tests: live gap recovery, high-volume concurrent exactly-once + ordering, KvLoader read coalescing under concurrency, and invalid-cursor error surfacing. Add a serial-vs-concurrent backfill benchmark (200 txs: 401 round trips / 1.0s serial vs 5 round trips / 79ms concurrent) plus a manual server harness.
tpham-mysten
added a commit
to MystenLabs/sui
that referenced
this pull request
Jul 31, 2026
The buffered subscription support lives on a fork branch; restore the amnn base for a mergeable manifest. Build is red until amnn/async-graphql#2 lands and the lock is bumped.
amnn
approved these changes
Jul 31, 2026
amnn
left a comment
Owner
There was a problem hiding this comment.
Looks reasonable to me! Just a small nit.
Not urgent but we can look to upstream this as well.
tpham-mysten
force-pushed
the
tpham-mysten/buffered-subscription-resolution
branch
from
July 31, 2026 16:04
f5d40c3 to
49ac083
Compare
Subscription payloads are resolved strictly serially (StreamExt::then in the derive), so a subscription resolving DB-backed fields does one backend round trip per payload with no DataLoader batching across payloads. Add a subscription_resolution_concurrency knob to SchemaBuilder (default 1, i.e. serial, so existing behavior is unchanged). When set > 1, the derive resolves up to N subscription items concurrently with buffered(N) (output order preserved via FuturesOrdered), so their DataLoader reads coalesce the same way a list's do within a payload. A server opts in with Schema::build(...).subscription_resolution_concurrency(n). The one correctness fix it needs: all items shared a single QueryEnvInner.errors sink drained per-item, which only works serially. Move errors from Arc<QueryEnvInner> onto QueryEnv and add fork_errors() so each concurrently-resolved item gets its own sink. Field shadowing keeps every existing errors read site unchanged, and queries/mutations never fork, so their behavior is untouched.
tpham-mysten
commented
Jul 31, 2026
tpham-mysten
left a comment
Author
There was a problem hiding this comment.
Thanks @amnn. I just asked Claude to upstream this on async-graphql#1833
8 tasks
tpham-mysten
added a commit
to MystenLabs/sui
that referenced
this pull request
Aug 5, 2026
…27537) ## Description Resolve subscription payloads concurrently rather than one at a time. A single `max_concurrent_resolutions` config drives both the resolve window (async-graphql's `subscription_resolution_concurrency`, now [merged](amnn/async-graphql#2)) and the backfill scan page, so a batch's matches resolve within the concurrency budget and coalesce their content reads into one `KvLoader` round trip. ## Test plan - e2e parity test (`test_transaction_subscription_live_backfill_parity`): the same transactions resolve identically whether delivered live or through the backfill scan, plus the existing streaming/ordering/resume subscription tests. - Batching e2e tests: `test_transaction_subscription_backfill_batches_matches` (a deep backfill packs matches into multi-edge payloads) and `test_transaction_subscription_live_batches_per_checkpoint` (each live payload is one checkpoint's matches). - Unit tests for the scan retry: recovers within the budget, gives up once it is exhausted. --- ## Stack - #26019 - #26094 - #26117 - #26170 - #26194 - #26202 - #26414 - #26453 - #26476 - #26487 - #26425 - #26495 - #26731 - #26714 - #27140 - #27537 ## Release notes Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required. For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates. - [ ] Protocol: - [ ] Nodes (Validators and Full nodes): - [ ] gRPC: - [ ] JSON-RPC: - [ ] GraphQL: - [ ] CLI: - [ ] Rust SDK: - [ ] Indexing Framework:
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.
What
Opt-in
SchemaBuilder::subscription_resolution_concurrency(n). Defaultn = 1is unchanged (serial). Withn > 1, up tonsubscription payloads resolve concurrently, in output order, so their per-payloadDataLoaderreads coalesce instead of one round trip per payload.Why
async-graphql resolves subscription payloads serially (
StreamExt::then), so a subscription emitting many payloads, each doing its ownDataLoaderreads, pays a round trip per payload. The usual workaround is to emit a batched list, which leaks the batch shape into the schema. Resolving payloads concurrently lets those reads coalesce like a hand-rolled batch, so an idiomatic one-item-per-payload subscription stays efficient without changing the schema. Decided in MystenLabs/sui#27140 (comment).How
thenbecomesbuffered(n)(ordered), so payloads resolve concurrently but deliver in submission order.QueryEnvInnerontoQueryEnv(Arc<Mutex<Vec<ServerError>>>), and each payload gets a fresh sink viafork_errors(). Without it, concurrently-resolved payloads would drain a shared sink and cross-contaminate errors. Queries and mutations never fork, so their behavior is unchanged.1(serial); values below 1 clamp to 1.Tests
test_subscription_resolution_concurrency: a barrier releases only if the payloads resolve concurrently (a timeout catches the serial case), and asserts output stays in submission order.test_subscription_resolution_error_isolation: several payloads record an error behind a barrier; each response must carry exactly its own. Fails withoutfork_errors.