Skip to content
Snippets Groups Projects
  1. Jul 30, 2019
  2. Jul 25, 2019
  3. Jul 16, 2019
  4. Jun 11, 2019
  5. Jun 10, 2019
  6. Jun 07, 2019
  7. Jun 06, 2019
  8. Apr 02, 2019
  9. Mar 06, 2019
  10. Feb 27, 2019
  11. Jan 30, 2019
  12. Jan 28, 2019
  13. Dec 21, 2018
  14. Nov 26, 2018
  15. Nov 17, 2018
  16. Sep 04, 2018
  17. Sep 03, 2018
  18. Sep 02, 2018
  19. Jul 23, 2018
  20. Jul 13, 2018
  21. Jul 05, 2018
  22. Jul 03, 2018
  23. Jul 02, 2018
  24. Jun 19, 2018
  25. May 25, 2018
  26. May 24, 2018
    • Noah Zentzis's avatar
      Recycle space when reserving from Vec-backed Bytes (#197) · dfce95b8
      Noah Zentzis authored
      * Recycle space when reserving from Vec-backed Bytes
      
      BytesMut::reserve, when called on a BytesMut instance which is backed by
      a non-shared Vec<u8>, would previously just delegate to Vec::reserve
      regardless of the current location in the buffer. If the Bytes is
      actually the trailing component of a larger Vec, then the unused space
      won't be recycled. In applications which continually move the pointer
      forward to consume data as it comes in, this can cause the underlying
      buffer to get extremely large.
      
      This commit checks whether there's extra space at the start of the
      backing Vec in this case, and reuses the unused space if possible
      instead of allocating.
      
      * Avoid excessive copying when reusing Vec space
      
      Only reuse space in a Vec-backed Bytes when doing so would gain back
      more than half of the current capacity. This avoids excessive copy
      operations when a large buffer is almost (but not completely) full.
      dfce95b8
    • Noah Zentzis's avatar
      Recycle space when reserving from Vec-backed Bytes (#197) · 2d95683b
      Noah Zentzis authored
      * Recycle space when reserving from Vec-backed Bytes
      
      BytesMut::reserve, when called on a BytesMut instance which is backed by
      a non-shared Vec<u8>, would previously just delegate to Vec::reserve
      regardless of the current location in the buffer. If the Bytes is
      actually the trailing component of a larger Vec, then the unused space
      won't be recycled. In applications which continually move the pointer
      forward to consume data as it comes in, this can cause the underlying
      buffer to get extremely large.
      
      This commit checks whether there's extra space at the start of the
      backing Vec in this case, and reuses the unused space if possible
      instead of allocating.
      
      * Avoid excessive copying when reusing Vec space
      
      Only reuse space in a Vec-backed Bytes when doing so would gain back
      more than half of the current capacity. This avoids excessive copy
      operations when a large buffer is almost (but not completely) full.
      2d95683b
Loading