Repository navigation
feat!: share live GraphQL refreshes across identical subscriptions - #342
Merged
Merged
Conversation
One producer loop (src/graphql/subscribe.rs) drives catalog live roots and external read roots. Subscribers whose read compiles to the same (role, SQL, binds, cache scope) share one execution per change; each keeps its own hash gate, envelope and resume-exact catch-up. Live executions are capped per engine (live_concurrency, default 8); slow subscribers skip to the latest frame instead of stalling others; the entry is torn down with its last subscriber. 100 subscribers: 100 -> 1 execution per change. BREAKING CHANGE: live_subscriber_count counts producers (distinct reads), not subscribers; an external root's failed first read ends the stream instead of failing the subscription future. Implements [[tasks/v5-review-26]]
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
Origin sharing made live_subscriber_count count producers, so the gateway load test (CI-only, ignored) saw 1 origin subscription instead of 100 in the non-sharing modes. live_producer_count now counts shared reads and live_subscriber_count counts streams; the load test asserts the gateway's savings on subscriptions and one origin producer in every mode. Implements [[tasks/v5-review-26]]
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.
Task 26 stage B ([[tasks/v5-review-26]]): live delivery. Review findings 05 #7, #13, #19 and #11.
What changed
src/graphql/subscribe.rs) for catalog live roots and external read roots.external_roots.rshad a second, already-drifted copy, which is now gone. Both kinds stop on a closed hub.BindValuehas hand-writtenEq/Hash: floats compare by bits, JSON by the text sent to the driver.live_concurrency(n)(default 8, 0 rejected) caps first reads, refreshes and catch-ups together.Executions
Measured with
hundred_origin_subscribers_share_one_execution_per_change, written first and run against the old code:Findings
Breaking changes
live_producer_count()counts producers (distinct reads);live_subscriber_count()still counts subscription streams. Both are available in every graphql build. (b40553c fixed the first CI run: the gateway load test read origin producers as subscriptions.)live_concurrency,DEFAULT_LIVE_CONCURRENCY.LiveQueryStreamis backed by a boxed stream.Tests
New unit tests (
src/graphql/subscribe/tests.rs) use a counting fake read under paused tokio time. They cover:sessions_share_a_live_producer_only_when_their_binds_matchshows two tenants get 2 producers, and a second session for the same tenant joins the existing one.Run locally:
make test-local(real Postgres and compose services): 2,910 passed, 0 failed.distributed_leaderboard --features redis,graphqlwith Redis: 30 passed.tests/gateway-{portable,native}: OK.--include-ignored: 342 passed. e2e-celld: 31 passed. e2e-ui offline: OK.graphql_query_protocollive and hundred-subscriber tests, andgraphql_subscriptions_sqlite: 0 failures.Not done
tests/gateway-postgres/run.pyand JS (wire output unchanged). The ignored workerd load testseparate_origin_and_client_savingsnow passes locally in all 8 host/mode rows.