This repository was archived by the owner on Mar 4, 2026. It is now read-only.
fix: do not load google-gax at client startup#1517
Merged
schmidt-sebastian merged 5 commits intomasterfrom May 27, 2021
Merged
Conversation
thebrianchen
approved these changes
May 26, 2021
| return v1beta1; | ||
| }, | ||
| // scope, we lazy-load the module. | ||
| get: () => require('./v1beta1'), |
There was a problem hiding this comment.
If require() automatically caches, the modules it loads, why did we cache the modules on this class to begin with?
Contributor
Author
There was a problem hiding this comment.
Coding is a learning opportunity for all of us.
| } | ||
| } | ||
|
|
||
| let serviceConfig: undefined | {[k: string]: CallSettings}; |
There was a problem hiding this comment.
nit: flip undefined to the other side
inlined
reviewed
May 27, 2021
inlined
left a comment
There was a problem hiding this comment.
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% |
gcf-merge-on-green bot
pushed a commit
that referenced
this pull request
May 27, 2021
🤖 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 was referenced May 27, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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: