-
Notifications
You must be signed in to change notification settings - Fork 149
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
fix: do not load google-gax at client startup #1517
Conversation
return v1beta1; | ||
}, | ||
// scope, we lazy-load the module. | ||
get: () => require('./v1beta1'), |
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.
If require()
automatically caches, the modules it loads, why did we cache the modules on this class to begin with?
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.
Coding is a learning opportunity for all of us.
dev/src/util.ts
Outdated
@@ -158,13 +144,28 @@ export function isPermanentRpcError( | |||
} | |||
} | |||
|
|||
let serviceConfig: undefined | {[k: string]: CallSettings}; |
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.
nit: flip undefined to the other side
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.
Done
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.
I ran my benchmark agains this branch. The benchmark uses 60 shards which will each try 20 times to purge the require cache and load both the firebase-functions
SDK and execute the boilerplate that happens in the cold start for a Firestore function. Here are my results:
stat. | vanilla | optimized | savings |
---|---|---|---|
mean | 335 | 253 | 24% |
p50 | 273 | 224 | 18% |
p90 | 513 | 485 | 5% |
p95 | 911 | 589 | 35% |
p99 | 1498 | 1150 | 23% |
🤖 I have created a release \*beep\* \*boop\* --- ### [4.12.1](https://www.github.com/googleapis/nodejs-firestore/compare/v4.12.0...v4.12.1) (2021-05-27) ### Bug Fixes * do not load google-gax at client startup ([#1517](https://www.github.com/googleapis/nodejs-firestore/issues/1517)) ([2141b08](https://www.github.com/googleapis/nodejs-firestore/commit/2141b0879cbccb1354f9821edcc917b6aa4ff0ab)) * recursive delete: backporting changes from Java ([#1514](https://www.github.com/googleapis/nodejs-firestore/issues/1514)) ([92ea651](https://www.github.com/googleapis/nodejs-firestore/commit/92ea651adc84ba854ae7cd203af231573f885307)) * return results from getPartitions() in order ([#1521](https://www.github.com/googleapis/nodejs-firestore/issues/1521)) ([c8168a8](https://www.github.com/googleapis/nodejs-firestore/commit/c8168a83a864dd77f88b1743adcd3568671702fe)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
This improves performance for functions users that only read data from the provided DocumentSnapshot, but do not otherwise access Firestore.
Test file (from @inlined): https://gist.github.com/schmidt-sebastian/f42c30d75785fba436746f894948ecf4
Extra dependencies loaded before PR:
After:
Cold start time from firebase-functions:
Code: