-
-
Notifications
You must be signed in to change notification settings - Fork 678
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
Optimize resolvers execution paths #488
Conversation
Codecov Report
@@ Coverage Diff @@
## master #488 +/- ##
==========================================
+ Coverage 95.14% 95.18% +0.04%
==========================================
Files 75 76 +1
Lines 1318 1329 +11
Branches 252 256 +4
==========================================
+ Hits 1254 1265 +11
Misses 61 61
Partials 3 3
Continue to review full report at Codecov.
|
@sixmen |
This comment has been minimized.
This comment has been minimized.
Lesson 1: always build your code before running 😄
So this makes sense to bloat the code with the fast sync path 🤔 |
I also don't like unnecessary optimization that ruins the code. (It may be unreal cases, but I faced the case as #254 shown. So I tried to minimize the change. I just made this PR to show you the possibility of optimization. I added the benchmark commit, and following is the result from my computer (MacBook Pro i7 2.6GHz)
|
I wonder why field resolvers are still 50% slower than the raw @sixmen please mark allowing changes to a pull request branch created from a fork as I want to push benchmark results 😉 |
@MichalLytek do you mean "Allow edits from maintainers."? I enabled it. I will also look for more bottlenecks, if I had time. |
I found another possibility. In my project, convertToType causes a problem. An ObjectType class of my project has a read-only field (using Object.defineProperty). If I changes |
|
361cd9a
to
21247d1
Compare
Fun story - |
Two are different:
More accurate version may be https://github.com/then/is-promise/blob/master/index.js, I copied it from https://github.com/graphql/graphql-js/blob/master/src/jsutils/isPromise.js. |
Right, both me and TypeScript forgot that the 'in' operator can be used only on objects, not primitives. |
21247d1
to
4887464
Compare
4887464
to
ac6548a
Compare
@sixmen I've also added a benchmark case when The last thing I have to do in this PR is to update the performance docs with this insights. |
d6f6ad3
to
5cf7984
Compare
5cf7984
to
967e537
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
When you will release this commit? I need to decide whether waiting next release or using beta release. |
Fixes #487