Skip to content
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

Major performance improvement #3

Merged
merged 3 commits into from
May 12, 2017
Merged

Major performance improvement #3

merged 3 commits into from
May 12, 2017

Commits on May 10, 2017

  1. Major performance improvement

    `Reader.prototype.addChunk` was calling `Buffer.concat` constantly, which
    increased garbage collection and just all-around killed performance. The
    exact implications of this is documented in
    brianc/node-postgres#1286, which has a test case
    for showing how performance is affected.
    
    Rather than concatenating buffers to the new buffer size constantly, this
    change uses a growth strategy that doubles the size of the buffer each
    time and tracks the functional length in a separate `chunkLength` variable.
    This significantly reduces the amount of allocation and provides a 25x
    performance in my test cases, the larger the amount of data the query
    is returning, the greater improvement of performance.
    
    Since this uses a doubling buffer, it was important to avoid growing
    forever, so I also added a reclaimation strategy which reduces the size
    of the buffer wever time more than half of the data has been read.
    mramato committed May 10, 2017
    Configuration menu
    Copy the full SHA
    0b95e3c View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    9c41ee6 View commit details
    Browse the repository at this point in the history

Commits on May 11, 2017

  1. Changes after review

    1. Fix Node @v0.10.x by removing `Buffer.alloc` usage.
    2. Remove uneeded Reader.prototype._save/
    3. Reset buffer at the end of the packet instead of shrinking dynamically.
    4. Remove some semi-colons to keep style consistent.
    mramato committed May 11, 2017
    Configuration menu
    Copy the full SHA
    626066b View commit details
    Browse the repository at this point in the history