Uploaded image for project: 'HttpComponents HttpCore'
  1. HttpComponents HttpCore
  2. HTTPCORE-518

Improve buffer allocation

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Minor
    • Resolution: Won't Fix
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: HttpCore NIO
    • Labels:
      None

      Description

      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:

      /**
      * 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;
        }
      ...
      }
      

       What do you think?

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              herrmess Ion Moldovan
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: