Repository navigation
Improve performance for large requests - #1066
Merged
Merged
Conversation
The code that handles the generation of request payloads was rewritten to make use of JavaScript generators to build payload data in a just-in-time fashion, instead of generating the whole payload upfront. This new approach to payload generation greatly reduces memory usage and the number of garbage collection runs, and indirectly also improves performance.
arthurschreiber
force-pushed
the
arthur/request-performance-feat
branch
from
March 7, 2020 20:10
2aff173 to
6b1d2e4
Compare
Codecov Report
@@ Coverage Diff @@
## master #1066 +/- ##
==========================================
+ Coverage 79.74% 80.68% +0.93%
==========================================
Files 86 86
Lines 4374 4374
Branches 789 789
==========================================
+ Hits 3488 3529 +41
+ Misses 629 586 -43
- Partials 257 259 +2
Continue to review full report at Codecov.
|
Collaborator
Author
|
🎉 This PR is included in version 8.1.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The code that handles the generation of request payloads was rewritten to make use of JavaScript generators to build payload data in a just-in-time fashion, instead of generating the whole payload upfront. This new approach to payload generation greatly reduces memory usage and the number of garbage collection runs, and indirectly also improves performance.
#1037, #1044, #1049 and #1063 contained the actual changes.
To show the improvements, we tracked memory usage while running the
benchmarks/query/insert-varbinary.jsbenchmark withsize=104857600 n=10(100MB of data) usingprocess.memoryUsage(), at an interval of500ms:Here is the same data collected with the new payload generation code:
As can be seen pretty clearly, the external memory value (which is tracking Buffer memory usage, amongst other things), was greatly reduced. This is mostly due to the fact that we don't build the whole request payload upfront anymore.
This reduction in memory usage can also lead to performance improvements - e.g. by reducing memory pressure, we also reduce the number of garbage collection runs, which should also improve overall application performance.
These improvements are very much dependent on the size of the request data, requests that send large data to the server should see big improvements, while smaller requests might only see minimal or no improvements at all.
Fixes: #971
Fixes: #475
Fixes: #879