Add fiber-based batch loading API - #3264
Merged
Merged
Conversation
Owner
Author
|
I added a really simple benchmark for comparing no batching / graphql-batch / graphql-dataloader. (Any suggestions for improving it?) It looks like GraphQL-Dataloader has about half the runtime overhead of GraphQL-Batch. As for memory,
The biggest impacts are: Those are:
It looks to me like those classes (Fiber, Hash) make up most of the overhead:
cc @swalkinshaw who expressed interest in seeing a benchmark |
Owner
Author
|
I was able to reduce the overhead a bit, now dataloader's memory footprint is smaller than graphql-batch for that benchmark: |
This was referenced Jan 6, 2021
Closed
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.
This could be pretty awesome. @bessey first suggested this on Twitter, and combined with a trampolining-like refactor, it might just work!
TL;DR: Use
Fiber.yieldto halt GraphQL execution in place; allow GraphQL fields toFiber.yieldand then they're resumed once every branch has reached a halt.The coolest thing is, if we can make
InterpreterFiber-aware, then we lay the groundwork for Ruby 3's Fiber scheduler API, and we'd get parallel IO "for free" (we have to implement a scheduler, and somehow implement that baton-passing).Goals:
lazy_resove) etcIf this works, I'll drop #2483
TODO:
Does it need a fiber pool?I don't think so -- I think Ruby is pretty thrifty with Fibers. If we need this later, we can replacewaiting_fibers = []with a more sophisticated blocking queue.Fiber.yieldisn't usedNullDataloader, which runs eagerly -- it's the defaultThread.current[...]assignments intocontext.Try out Ruby 3's scheduler?I'm going to put this off.dataloader.yieldfor manual parallelism