-
-
Notifications
You must be signed in to change notification settings - Fork 676
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
Too slow for simple large list #254
Comments
Note: partially related to #71. @sixmen If you are interested in making TypeGraphQL faster, you should consider creating more real-life benchmarks, where you call http endpoint, read from databse, write from database, have inputs validation, some auhtorization guard mechanism, middlewares for catching and transforming results, etc. In this more complicated scenario, the difference will be much smaller cause the most of time it will execute arbitrary user code, not the framework internals. I can make |
Actually this is a REAL problem for me. My program reads data of length 500 from database and returns as list. And no middleware are applied to the fields. If the DB time is 200ms, type-graphql is still very slow (300ms vs 100ms). This is a graph when I remove type-graphql runtime (decorators remain, and build schema from decorators at compile time) |
For my problem, following shortcuts are enough because I don't have global middlewares.
OR
If someone has global middlewares, some methods to skip middlewares(like {simple:true}) may be needed. |
When #183 arrives, I can definitely detect if the resolver has some middlewares or other things attached and then can decide if use an advanced resolver or just the simple one (or even no resolver to let the I will take care of that problem after some benchmarks #71. |
What is the resolution for this issue? i have this exact same problem. @MichalLytek |
Note: it's not only slow but it consumes ridiculous amount of memory. In our case, we had to increase memory from 192MB to 2GB to prevent crashing |
@theodorDiaconu What would be the use case when you wan't to strip off authorization or other middlewares? |
@MichalLytek I have tested the implementation in this description. We're having big problems. I wanted to further test and play with the example. The simple graphql returns 50,000 generated docs in 508ms. The type-graphql returns 2000 docs in 752ms. Something is really really off. For 50,000 and type-graphql
It seems that the amount of time grows exponentially not lineraly which leads me to think there's something else going on here. |
Did some research and it seems it's related to the
As it turns out the lib awaiter was heavy, just modifying to |
@theodorDiaconu This would allow us to work on the performance problem together rather than "fixing" code without knowing the real influence on this 😉 |
Can confirm that compiling with higher target makes things faster ~2x node 12 also fixes #449 |
As Node 8 is going out of support, we can bump to 10.3 and use ES2018 features 💪 |
I've created a simple benchmark which showed that it speeds up the execution of simple object returning from 4831 ms to 2196 ms, and deeply nested object from 17067 ms to 7311 ms! 💪 But it's still 2196 ms vs 871 ms of Will check the behavior for big arrays of object and then add an option to disable TypeGraphQL resolver stack in favor of direct object field access 😉 |
Second discover - Node 13 is really fast! 🚀 Also, using default resolvers for object fields increase the speed for nested objects from 4.557s to 3.086s, which is really close to 2.422s of Now after confirmation I can work on API to enable that optimization 😉 |
@Lurk @theodorDiaconu @trubi @preetb123 @sixmen |
@MichalLytek thanks for your work here in improving the performance. In our project we ran into massive performance problems with your library. Only 3 request per seconds will max out a single node instance with 220% CPU usage (2017 MacBook Pro). The related query consists of a very complex and big tree of objects with total size of about 320 kb. The new beta version already improves the situation a lot. However it is very cumbersome to add this annotation to all object types. Since we currently don't have any middleware at all we would would much appreciate a global switch for the behavior. Or even better that the framework detects there is no middleware and skips the overhead. |
I agree but it's not so simple to do this detection right now, so please use the workaround for now. |
Good job @MichalLytek on the performance improvements. I stopped iterating on it. I decided for now to stay away from any "Abstraction Layer" on top of GraphQL official schema. This might change in the future, as your library is the best out there, it's properly maintained and it's clear that you care about it. Another concern that I expressed both on gitter is that you are the sole developer. A good developer nonetheless, but I cannot base a medical enterprise application on a framework maintained by a SINGLE developer, way to risky. GraphQL is moving fast, and most likely this isn't your full time job. Try to think of a tooling that you can offer to assist developing your framework and sell it, or write a book, or try to find some case-studies from successful projects using this, get some insight, and you can also assemble a team and leverage that to offer paid enterprise support and training. Then, people like me who are scared as **** of code-base abandonment will no longer think this. |
I checked the beta, and the issue I created is resolved. But I found another problem after I created the issue. So, I made another issue #487, please check it. |
I understand your point of view as for enterprise grade products you need a solid, stable and well supported products. However, be aware that "official"
I have some sponsorship from companies, I have backers on OpenCollective so I hope things will move forward into less hobbyist, more stable part-time maintaining 😉 I don't want to go into a paid plan, especially not now when TypeGraphQL just started adopting in GraphQL community. For workshops and training it also might be too early but I am always open for any request. Maybe a paid course on a learning platform would be a good fit I think 🤔 Also, in Gold Sponsors tier, you will "get a premium technical support from our core contributors", so if you only need a support with solving problems, fixing bugs or adding new features in TypeGraphQL for your enterprise app, and you are able to pay for this, it's not a problem as I run my own business and can send an invoice for that 😉 |
Is your feature request related to a problem? Please describe.
type-graphql is slower than normal graphql for simple large list.
type-graphql:
time = 920
normal graphql:
time = 101
Describe the solution you'd like
I think some optimizations are needed for simple cases.
If I change createSimpleFieldResolver, it runs faster.
The text was updated successfully, but these errors were encountered: