JamesGuthrie opened a new pull request, #3212:
URL: https://github.com/apache/thrift/pull/3212

   In the context of THRIFT-5322 commit 37c2ceb7 introduced the safeReadBytes 
method, which prevents allocating very large buffers on malformed input by 
using a bytes.Buffer as the backing buffer to contain data.
   
   Due to how io.CopyN and bytes.Buffer interact, and bytes.Buffer's grow 
behaviour, the smallest buffer size is 512 bytes, but typically buffer sizes 
are at least 1024 bytes. In degenerate cases (reading many small fields) this 
can cause significant bloat, e.g. a value of 8 bytes in length sits in a buffer 
of 1024 bytes.
   
   This change eliminates bloat by allocating an array of exactly the desired 
size, when the desired size is below bytes.Buffer's minimum buffer size.
   
   <!-- We recommend you review the checklist/tips before submitting a pull 
request. -->
   
   - [ ] Did you create an [Apache 
Jira](https://issues.apache.org/jira/projects/THRIFT/issues/) ticket?  
([Request account here](https://selfserve.apache.org/jira-account.html), not 
required for trivial changes)
   - [ ] If a ticket exists: Does your pull request title follow the pattern 
"THRIFT-NNNN: describe my issue"?
   - [x] Did you squash your changes to a single commit?  (not required, but 
preferred)
   - [x] Did you do your best to avoid breaking changes?  If one was needed, 
did you label the Jira ticket with "Breaking-Change"?
   - [x] If your change does not involve any code, include `[skip ci]` anywhere 
in the commit message to free up build resources.
   
   <!--
     The Contributing Guide at:
     https://github.com/apache/thrift/blob/master/CONTRIBUTING.md
     has more details and tips for committing properly.
   -->
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to