You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Ion Moldovan (JIRA)" <ji...@apache.org> on 2018/03/16 15:52:00 UTC
[jira] [Created] (HTTPCORE-518) Improve buffer allocation
Ion Moldovan created HTTPCORE-518:
-------------------------------------
Summary: Improve buffer allocation
Key: HTTPCORE-518
URL: https://issues.apache.org/jira/browse/HTTPCORE-518
Project: HttpComponents HttpCore
Issue Type: Improvement
Components: HttpCore NIO
Reporter: Ion Moldovan
The doubling of the buffer size every time it exceeds its previous size is a good way for small buffers, but quite wasteful for large sizes.
A more modest growth (e.g. 1.25 x Previous Size) when sizes are > 32MB would be a nice improvement.
Proposed solution:
{code:java}
/**
* Expands buffer's capacity.
*
* @throws BufferOverflowException in case we get over the maximum allowed value
*/
protected void expand() throws BufferOverflowException {
int newcapacity;
if (this.buffer.capacity() <= (32 << 20) ) {
newcapacity = (this.buffer.capacity() + 1) << 1;
} else {
newcapacity = (this.buffer.capacity() + 1) * 5 / 4;
}
...
}
{code}
What do you think?
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org