Skip to content
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

Is there a performance benchmark? #238

Open
CreatCodeBuild opened this issue Mar 7, 2020 · 8 comments
Open

Is there a performance benchmark? #238

CreatCodeBuild opened this issue Mar 7, 2020 · 8 comments

Comments

@CreatCodeBuild
Copy link

I use GraphQL and Dataloader in production. I have experienced some performance issues with Dataloader because our code might create 1,000+ promises per second by using Dataloader.

Not necessarily a performance issue with Dataloader itself, but I would like to understand more performance metrics of Dataloader itself in order to optimize my code.

@CreatCodeBuild
Copy link
Author

If there isn't one already, are current tests a good approximation of the performance?

@Bajix
Copy link

Bajix commented Nov 3, 2021

I'm curious about this as well, just as a gauge of comparative performance. In Rust this could be done in as little as 8 microseconds, but I imagine in JS this is thousands of times slower.

@laurisvan
Copy link

DataLoaders are currently our main memory hog, indeed creating 1000s of Promises, JS context objects or array literals as we have a few levels of GraphQL resolvers, resolving up a few tens of thousands of objects. At this level, V8 garbage collection starts to become a bit of problem.

I traced some of the problems to the .load() function, creating a new Promise and such for every call. I am currently investingating if I could create an alternative that could somehow reuse the same Promise accross multiple load() calls.

@nicoabie
Copy link

nicoabie commented May 7, 2023

DataLoaders are currently our main memory hog, indeed creating 1000s of Promises, JS context objects or array literals as we have a few levels of GraphQL resolvers, resolving up a few tens of thousands of objects. At this level, V8 garbage collection starts to become a bit of problem.

I traced some of the problems to the .load() function, creating a new Promise and such for every call. I am currently investingating if I could create an alternative that could somehow reuse the same Promise accross multiple load() calls.

Any findings?

@laurisvan
Copy link

@nicoabie Unfortunately not yet - we've been too busy with other things. We kicked the can forward by compiling node.js with pointer compression. That reduced our memory load enough that this is not currently our biggest challenge.

@laurisvan
Copy link

This morning I had a moment to think about this, yet still nothing concrete yet :(

I was wondering - perhaps async generators would work here. The problems raised at graphql-js repo seem a bit similar: graphql/graphql-js#2262

@nicoabie
Copy link

nicoabie commented Jun 5, 2023

As far as I could understand, their problem is with blocking and here is with a lot of memory being used creating new promises. I don't see how the async generators would prevent creating the large amount of promises. 😕

@laurisvan
Copy link

I must say I'm not expert on async generators either - I don't know what the underlying mechanism is, e.g. does it create context objects in the same way as Promises do. At least in my case the biggest problem is not the memory used, but the fact that every object allocated from heap needs to be garbage collected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants