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

Improve buffer allocation

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Won't Fix
    • None
    • None
    • HttpCore NIO
    • 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

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

            Dates

              Created:
              Updated:
              Resolved: