René's URL Explorer Experiment
Title: Skip data loaders with no queued keys in ticker-mode dispatchAll by Meemaw · Pull Request #293 · graphql-java/java-dataloader · GitHub
Open Graph Title: Skip data loaders with no queued keys in ticker-mode dispatchAll by Meemaw · Pull Request #293 · graphql-java/java-dataloader
X Title: Skip data loaders with no queued keys in ticker-mode dispatchAll by Meemaw · Pull Request #293 · graphql-java/java-dataloader
Description: Fixes #292.
In ticker mode, dispatchAll() ran a full dispatch() on every registered data loader, including loaders with nothing queued. A request's registry usually holds many more loaders than any one dispatchAll() has work for, and graphql-java calls dispatchAll() many times per request. Most of the work, and roughly 48 bytes of allocation per idle loader per call, went to loaders with empty queues. #292 has the profile data.
Change
In ticker mode, dispatchAllWithCount() now:
re-arms the ticker once, before dispatching, so a throwing loader or predicate still can't stop it;
then dispatches only loaders with dispatchDepth() > 0 whose predicate passes. dispatchDepth() is a single atomic read of the queue head.
Non-ticker mode is unchanged. There, a loader whose predicate says no keeps its own reschedule chain, and that behaviour is left as is.
Behaviour
Preserved: after the first dispatchAll(), every loader whose predicate passes is dispatched at least every schedule until close(). A key queued after the depth check is dispatched by the next tick, the same window as a key queued just after a dispatch today.
Preserved: the close() semantics from #291, and the ticker surviving a throwing predicate.
Changed, idle loaders only:
Predicates are no longer evaluated for loaders with nothing queued.
beginDispatch instrumentation no longer fires for them.
Their lastDispatchTime is no longer refreshed. The only built-in reader is DispatchPredicate.dispatchIfLongerThan. With it, the first key queued after an idle period now dispatches on the next dispatchAll(), rather than waiting duration after the last empty dispatch. "Time since dispatch" then means time since the last dispatch that did something.
Benchmark
This adds ScheduledDataLoaderRegistryDispatchPerformance (JMH). It builds a ticker-mode registry the way DGS does: DISPATCH_NEVER for the registry, DISPATCH_ALWAYS per loader, and an hour-long schedule so the ticker never fires during a measurement. Caching is off so every load is queued. Each operation queues one key on N loaders, then calls dispatchAllWithCount().
The runs were on JDK 21, Apple M-series, with -prof gc. Each variant ran twice (one fork, 3×2 s warmup, 5×2 s measurement), interleaving master and this branch. Another JMH workload was running on the machine at the same time, so treat the absolute numbers as indicative. The ranges below span both runs.
Registered loaders
Loaders with queued keys
master (da59d1d)
This PR
Speed-up
20
0
853–881 ns, 960 B
59–60 ns, 0 B
~14×
200
0
9,199–9,468 ns, 9,600 B
677–688 ns, 0 B
~14×
20
5
1,129–1,199 ns, 3,920 B
575–610 ns, 2,840 B
~1.9×
200
5
9,766–10,069 ns, 16,600–16,880 B
1,560–1,588 ns, 2,840 B
~6.3×
With this change, the cost of a dispatchAll() that has work no longer depends on how many loaders are registered: 2,840 B per call with 20 or 200 loaders. Run the benchmark with ./gradlew jmhJar, then java -jar build/libs/*-jmh.jar ScheduledDataLoaderRegistryDispatchPerformance -prof gc.
End-to-end. We ran a graphql-java 25 workload with DGS-style ticker registries: 200 loaders, a query fanning out to 12 of them over three nested levels, 3 ms simulated I/O, and 48 concurrent requests. With this change applied:
one idle dispatchAll() went from 32.3 µs to 2.5 µs;
process CPU per request went from 25.1 to 23.4 ms (−7%, mean of 3 runs).
We've applied the same change as a local patch to our service. Based on the profile in #292, we expect it to remove most of the ~3% of CPU that went to empty dispatches.
Tests
New: ticker_mode_dispatch_all_only_visits_data_loaders_with_queued_keys. It uses 20 loaders with one queued key, and asserts:
only that loader's predicate runs;
its load completes;
the count is 1;
one tick is pending.
Without the dispatchDepth() check it fails, because the predicate runs for all 20 loaders.
The existing ticker tests from #291 still pass: one pending task, rescheduleNow, ticking after a throwing predicate, and close.
./gradlew build on JDK 21 passes.
Open Graph Description: Fixes #292.
In ticker mode, dispatchAll() ran a full dispatch() on every registered data loader, including loaders with nothing queued. A request's registry usually holds many more loaders than...
X Description: Fixes #292.
In ticker mode, dispatchAll() ran a full dispatch() on every registered data loader, including loaders with nothing queued. A request's registry usually holds many more loaders ...
Opengraph URL: https://github.com/graphql-java/java-dataloader/pull/293
X: @github
direct link
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:c87e53d8-e3e9-bd7e-4688-eb8d09549f2f |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | C8B4:2A5566:1CE351:25F880:6B01885D |
| html-safe-nonce | f69ca7eb0eaef7787f224b0a7dfa97f3e198ad717c8bd9ab32f916e680d5061b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDOEI0OjJBNTU2NjoxQ0UzNTE6MjVGODgwOjZCMDE4ODVEIiwidmlzaXRvcl9pZCI6Ijg4NDUwNDc2Njg0NzA3OTMzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | f8d30fdf6206b5bc5076edee8ab2e7cc01812d3b9fbbb472aef7980d994cd7a8 |
| hovercard-subject-tag | pull_request:4918544604 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | ///pull_requests/show/files |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/graphql-java/java-dataloader/pull/293/files |
| twitter:image | https://avatars.githubusercontent.com/u/8524109?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/8524109?s=400&v=4 |
| og:image:alt | Fixes #292.
In ticker mode, dispatchAll() ran a full dispatch() on every registered data loader, including loaders with nothing queued. A request's registry usually holds many more loaders than... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/graphql-java/java-dataloader git https://github.com/graphql-java/java-dataloader.git |
| octolytics-dimension-user_id | 14289921 |
| octolytics-dimension-user_login | graphql-java |
| octolytics-dimension-repository_id | 97364654 |
| octolytics-dimension-repository_nwo | graphql-java/java-dataloader |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 97364654 |
| octolytics-dimension-repository_network_root_nwo | graphql-java/java-dataloader |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
| Skip to content | https://github.com/graphql-java/java-dataloader/pull/293/files#start-of-content |
| https://github.com/ |
| Sign in | https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgraphql-java%2Fjava-dataloader%2Fpull%2F293%2Ffiles |
| GitHubRepository hosting, code review, and collaboration | https://github.com/platform |
| CopilotAI coding agent for tasks, projects, and automated work | https://github.com/features/copilot |
| ActionsCI/CD and automation | https://github.com/features/actions |
| Code QualityQuality analysis, fixes, and enforcement | https://github.com/features/code-quality |
| CodespacesCloud development environments | https://github.com/features/codespaces |
| Code SecurityVulnerability detection and remediation | https://github.com/security/advanced-security/code-security |
| Secret ProtectionSecret scanning and leak prevention | https://github.com/security/advanced-security/secret-protection |
| All Features | https://github.com/features |
| Documentation | https://docs.github.com/en |
| Training | https://learn.github.com/skills |
| Certifications | https://learn.github.com/credentials |
| Build with Copilot | https://github.com/features/ai |
| Customize Copilot | https://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview |
| Integrations | https://github.com/marketplace |
| Trending repos | https://github.com/trending |
| GitHub Sponsors | https://github.com/open-source/sponsors |
| Developer articles | https://github.com/resources/articles |
| ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place. | https://github.blog/changelog/ |
| Enterprises | https://github.com/enterprise |
| Team | https://github.com/team |
| Startups | https://github.com/enterprise/startups |
| Nonprofits | https://github.com/solutions/industry/nonprofits |
| Healthcare | https://github.com/solutions/industry/healthcare |
| Financial services | https://github.com/solutions/industry/financial-services |
| Manufacturing | https://github.com/solutions/industry/manufacturing |
| Government | https://github.com/solutions/industry/government |
| See all industries | https://github.com/solutions/industry |
| Why GitHub | https://github.com/why-github |
| Customer Stories | https://github.com/customer-stories |
| Business insights | https://github.com/solutions/executive-insights |
| Trust Center | https://github.com/trust-center |
| GitHub Advanced SecurityEnterprise-grade code security | https://github.com/security/advanced-security |
| Copilot for businessEnterprise-grade AI features | https://github.com/features/copilot/copilot-business |
| Premium SupportEnterprise-grade 24/7 support | https://github.com/enterprise/premium-support |
| Documentation | https://docs.github.com/en |
| Resource center | https://github.com/resources |
| Blog | https://github.blog/ |
| Events & webinars | https://github.com/resources/events |
| Community Forum | https://github.com/orgs/community/discussions |
| Customer Stories | https://github.com/customer-stories |
| Integrations | https://github.com/marketplace |
| Customer support | https://help.github.com/ |
| Training | https://learn.github.com/skills |
| GitHub Status | https://www.githubstatus.com/ |
| About | https://github.com/about |
| Partners | https://github.com/partners |
| Changelog | https://github.blog/changelog/ |
| GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub. | https://githubuniverse.com/ |
| Pricing | https://github.com/pricing |
| Sign in | https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgraphql-java%2Fjava-dataloader%2Fpull%2F293%2Ffiles |
| Sign up | https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=graphql-java%2Fjava-dataloader |
| Reload | https://github.com/graphql-java/java-dataloader/pull/293/files |
| Reload | https://github.com/graphql-java/java-dataloader/pull/293/files |
| Reload | https://github.com/graphql-java/java-dataloader/pull/293/files |
| graphql-java | https://github.com/graphql-java |
| java-dataloader | https://github.com/graphql-java/java-dataloader |
| Code | https://github.com/graphql-java/java-dataloader |
| Issues2 (2) | https://github.com/graphql-java/java-dataloader/issues |
| Pull requests18 (18) | https://github.com/graphql-java/java-dataloader/pulls |
| Discussions | https://github.com/graphql-java/java-dataloader/discussions |
| Actions | https://github.com/graphql-java/java-dataloader/actions |
| Projects | https://github.com/graphql-java/java-dataloader/projects |
| Wiki | https://github.com/graphql-java/java-dataloader/wiki |
| Security and quality | https://github.com/graphql-java/java-dataloader/security |
| Insights | https://github.com/graphql-java/java-dataloader/insights |
| Sign up for GitHub
| https://github.com/signup?return_to=%2Fgraphql-java%2Fjava-dataloader%2Fissues%2Fnew%2Fchoose |
| terms of service | https://docs.github.com/terms |
| privacy statement | https://docs.github.com/privacy |
| Sign in | https://github.com/login?return_to=%2Fgraphql-java%2Fjava-dataloader%2Fissues%2Fnew%2Fchoose |
| bbakerman | https://github.com/bbakerman |
| graphql-java:master | https://github.com/graphql-java/java-dataloader/tree/master |
| Meemaw:ticker-mode-skip-idle-loaders | https://github.com/Meemaw/java-dataloader/tree/ticker-mode-skip-idle-loaders |
|
Conversation
1
| https://github.com/graphql-java/java-dataloader/pull/293 |
|
Commits
1
| https://github.com/graphql-java/java-dataloader/pull/293/commits |
|
Checks
1
| https://github.com/graphql-java/java-dataloader/pull/293/checks |
|
Files changed
| https://github.com/graphql-java/java-dataloader/pull/293/files |
| Please reload this page | https://github.com/graphql-java/java-dataloader/pull/293/files |
|
Skip data loaders with no queued keys in ticker-mode dispatchAll
| https://github.com/graphql-java/java-dataloader/pull/293/files#top |
|
Show all changes
1 commit
| https://github.com/graphql-java/java-dataloader/pull/293/files |
|
2659816
Skip data loaders with no queued keys in ticker-mode dispatchAll
Meemaw Oct 19, 2026
| https://github.com/graphql-java/java-dataloader/pull/293/commits/2659816f8c2a21aa63725ca22a637810ab34791e |
|
Clear filters
| https://github.com/graphql-java/java-dataloader/pull/293/files |
| Please reload this page | https://github.com/graphql-java/java-dataloader/pull/293/files |
| Please reload this page | https://github.com/graphql-java/java-dataloader/pull/293/files |
|
ScheduledDataLoaderRegistryDispatchPerformance.java
| https://github.com/graphql-java/java-dataloader/pull/293/files#diff-b073c4bd489b00a56bac4d5dc55273a22ab6f8b65f0cb6902a063acbb3d25870 |
|
ScheduledDataLoaderRegistry.java
| https://github.com/graphql-java/java-dataloader/pull/293/files#diff-80b84eb93b557ef760c8d07f70cc14f607381d095fb5ba1e9dd96465446fce31 |
|
ScheduledDataLoaderRegistryTest.java
| https://github.com/graphql-java/java-dataloader/pull/293/files#diff-e99c2733e4dd81edb1e1f555da5553e6e58c735d7c1b4ee14f120fab682daf6d |
| src/jmh/java/performance/ScheduledDataLoaderRegistryDispatchPerformance.java | https://github.com/graphql-java/java-dataloader/pull/293/files#diff-b073c4bd489b00a56bac4d5dc55273a22ab6f8b65f0cb6902a063acbb3d25870 |
|
View file
| https://github.com/Meemaw/java-dataloader/blob/2659816f8c2a21aa63725ca22a637810ab34791e/src/jmh/java/performance/ScheduledDataLoaderRegistryDispatchPerformance.java |
|
Open in desktop
| https://desktop.github.com |
| https://github.co/hiddenchars |
| https://github.com/graphql-java/java-dataloader/pull/293/{{ revealButtonHref }} |
| src/main/java/org/dataloader/registries/ScheduledDataLoaderRegistry.java | https://github.com/graphql-java/java-dataloader/pull/293/files#diff-80b84eb93b557ef760c8d07f70cc14f607381d095fb5ba1e9dd96465446fce31 |
|
View file
| https://github.com/Meemaw/java-dataloader/blob/2659816f8c2a21aa63725ca22a637810ab34791e/src/main/java/org/dataloader/registries/ScheduledDataLoaderRegistry.java |
|
Open in desktop
| https://desktop.github.com |
| https://github.co/hiddenchars |
| https://github.com/graphql-java/java-dataloader/pull/293/{{ revealButtonHref }} |
|
| https://github.com/graphql-java/java-dataloader/pull/293/files#diff-80b84eb93b557ef760c8d07f70cc14f607381d095fb5ba1e9dd96465446fce31 |
|
| https://github.com/graphql-java/java-dataloader/pull/293/files#diff-80b84eb93b557ef760c8d07f70cc14f607381d095fb5ba1e9dd96465446fce31 |
|
| https://github.com/graphql-java/java-dataloader/pull/293/files#diff-80b84eb93b557ef760c8d07f70cc14f607381d095fb5ba1e9dd96465446fce31 |
| src/test/java/org/dataloader/registries/ScheduledDataLoaderRegistryTest.java | https://github.com/graphql-java/java-dataloader/pull/293/files#diff-e99c2733e4dd81edb1e1f555da5553e6e58c735d7c1b4ee14f120fab682daf6d |
|
View file
| https://github.com/Meemaw/java-dataloader/blob/2659816f8c2a21aa63725ca22a637810ab34791e/src/test/java/org/dataloader/registries/ScheduledDataLoaderRegistryTest.java |
|
Open in desktop
| https://desktop.github.com |
| https://github.co/hiddenchars |
| https://github.com/graphql-java/java-dataloader/pull/293/{{ revealButtonHref }} |
|
| https://github.com/graphql-java/java-dataloader/pull/293/files#diff-e99c2733e4dd81edb1e1f555da5553e6e58c735d7c1b4ee14f120fab682daf6d |
|
| https://github.com/graphql-java/java-dataloader/pull/293/files#diff-e99c2733e4dd81edb1e1f555da5553e6e58c735d7c1b4ee14f120fab682daf6d |
| Please reload this page | https://github.com/graphql-java/java-dataloader/pull/293/files |
|
| https://github.com |
| Terms | https://docs.github.com/site-policy/github-terms/github-terms-of-service |
| Privacy | https://docs.github.com/site-policy/privacy-policies/github-privacy-statement |
| Security | https://github.com/security |
| Status | https://www.githubstatus.com/ |
| Community | https://github.community/ |
| Docs | https://docs.github.com/ |
| Contact | https://support.github.com?tags=dotcom-footer |
Viewport: width=device-width
URLs of crawlers that visited me.