-
Notifications
You must be signed in to change notification settings - Fork 2k
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
benchmark: test performance cost of re-creating schema #3596
Conversation
Nessary as part of a current and possible future disscussion on perfomance penalties of schema transformation.
✅ Deploy Preview for compassionate-pike-271cb3 ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
Hi @IvanGoncharov, I'm @github-actions bot happy to help you with this PR 👋 Supported commandsPlease post this commands in separate comments and only one per comment:
|
This comment has been minimized.
This comment has been minimized.
Benchmark output
🍳 Preparing HEAD... HEAD�[90m x �[0m�[32m454�[0m ops/sec �[90m±�[0m�[33m2.35�[0m�[36m%�[0m�[90m x �[0m121 KB/op�[90m (16 runs sampled)�[0m ⏱ Build Schema from AST HEAD�[90m x �[0m�[32m29.46�[0m ops/sec �[90m±�[0m�[32m1.70�[0m�[36m%�[0m�[90m x �[0m1.67 MB/op�[90m (6 runs sampled)�[0m ⏱ Build Schema from Introspection �[32mHEAD�[0m�[90m x �[0m�[32m34.82�[0m ops/sec �[90m±�[0m�[32m0.37�[0m�[36m%�[0m�[90m x �[0m1.78 MB/op�[90m (7 runs sampled)�[0m ⏱ Execute Introspection Query HEAD�[90m x �[0m�[32m 28.4�[0m ops/sec �[90m±�[0m�[32m1.28�[0m�[36m%�[0m�[90m x �[0m586 KB/op�[90m (5 runs sampled)�[0m ⏱ Parse introspection query �[32mHEAD�[0m�[90m x �[0m�[32m10,501�[0m ops/sec �[90m±�[0m�[32m0.09�[0m�[36m%�[0m�[90m x �[0m1.41 KB/op�[90m (26 runs sampled)�[0m ⏱ Validate Introspection Query �[32mHEAD�[0m�[90m x �[0m�[32m482�[0m ops/sec �[90m±�[0m�[32m0.30�[0m�[36m%�[0m�[90m x �[0m86.63 KB/op�[90m (10 runs sampled)�[0m ⏱ Validate Invalid Query �[32mHEAD�[0m�[90m x �[0m�[32m395�[0m ops/sec �[90m±�[0m�[32m0.24�[0m�[36m%�[0m�[90m x �[0m160 KB/op�[90m (9 runs sampled)�[0m ⏱ Validate SDL Document �[32mHEAD�[0m�[90m x �[0m�[32m44.59�[0m ops/sec �[90m±�[0m�[32m0.58�[0m�[36m%�[0m�[90m x �[0m346 KB/op�[90m (7 runs sampled)�[0m ⏱ Visit all AST nodes �[32mHEAD�[0m�[90m x �[0m�[32m190�[0m ops/sec �[90m±�[0m�[32m0.23�[0m�[36m%�[0m�[90m x �[0m288 KB/op�[90m (14 runs sampled)�[0m ⏱ Visit all AST nodes in parallel �[32mHEAD�[0m�[90m x �[0m�[32m18.25�[0m ops/sec �[90m±�[0m�[32m0.20�[0m�[36m%�[0m�[90m x �[0m437 KB/op�[90m (5 runs sampled)�[0m |
Hmmm. Am I write in reading this as about 450 ops/s = about 2.2 ms to recreate a schema? One note is that this is additive if a pipeline does this repeatedly. Note that at the last WG, we discussed not just simple schema recreation, but also potentially "rewiring" it, i.e. recreating all types that reference changed types. In Within |
Point of this benchmark is to prove that you can attach configuration to GraphQLSchema and force users to re-create schema if they want to change config.
Yes, it's additive but you can use caching (ES6 Map of transformation) if you want to do it per request. Also please note it's done for absolutely massive GitHub schema which is way way bigger that most users will ever have. |
We are optimizing for cold starts for lambda-like environments where caching is not possible. |
So if it's a per-request transformation (e.g. different schema based on headers, URL, etc.) when it can be cached. If transformation is done before starting the server, I think 2.2ms on a weak CI runner for GitHub size schema is not a big price to pay. |
I guess it's important to keep in mind the baseline cost of a cold start for the execution environment to spin up. https://mikhail.io/serverless/coldstarts/aws/ If it's usually 400 ms, then an extra 2 ms could represent some huge increase with respect to the user code, but still less than a 0.5% increase compared to the overall startup delay, not so important of an optimization after all! |
Whoops. Other solutions measure cold starts in ms time. https://blog.cloudflare.com/eliminating-cold-starts-with-cloudflare-workers/ Sorry for the multiple comments. |
Nessary as part of a current and possible future disscussion on perfomance penalties of schema
transformation.