-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build a Dataloader on Async gem primitives #4727
Conversation
This is a bit in the weeds for me to truly review, but I gave things a read through and it looks good! I'm happy you've been able to make some progress here, and excited for the Async-ified Dataloader! I see your todos in the PR description, and figured I'd share a bit of code I'm using in a Rails app running Falcon/Async and doing a lot of Async::HTTP work: https://gist.github.com/trevorturk/f8baeaf8a954bc3764d70652db1692fa -- one bit is around testing that things are running in parallel and the other is a fix for integration tests. I'll keep an eye on this PR and report back if I have anything useful to share. Feel free to ping me if you have any questions I might be able to help with. I'll also @ioquatix just in case he has the time/interest to put his eyes on this. |
I tried it in Rails and it worked like a charm! Net::HTTP and ActiveRecord ran in parallel without a problem. Demo: https://github.com/rmosolgo/rails-graphql-async-demo |
You can visualise what is going on using the |
I think I'm all set, application-wise. It's just CI -- it runs for hours but gets nowhere: https://github.com/rmosolgo/graphql-ruby/actions/runs/7196641771/job/19601940761 Actually, the Rails build (sometimes?) gets somewhere, but not too far: https://github.com/rmosolgo/graphql-ruby/actions/runs/7196641771/job/19601942904 I'm going to dig in and straighten it out tomorrow. |
It’s not uncommon for CI to expose race conditions because scheduling is so much slower and thus unpredictable. I would suggest looking at scheduling operations. |
I should add, tests that depend on |
🎉 It was scheduling code. Previously I was relying on loops going round and round to eventually let everything resolve. But I had a test to make sure that the dataloader loop didn't exceed 1000 iterations. It was -- in fact, it was neverending -- so the test suite never finished. I added an @ioquatix, this is hot stuff! Thanks for this great library. I look forward to learning more, for example, applying semaphores to the internal list of dataloader jobs if the need arises (it hasn't yet...). Edit: I got ahead of myself ... still a few commented-out tests to fix... |
Amazing. @ioquatix and @trevorturk, thanks again for your help along the way on this! |
Nice work team! |
This is another attempt to get Dataloader to "Just Work" when it comes to running
Source#fetch
in the background.This approach uses the
async
gem to handle backgrounding, usingAsync do ... end
.TODO:
Async { ... }.wait
, but I don't have a test for it at the moment.