[Libguestfs] [PATCH libnbd 0/9] golang: Safer, easier to use, and faster AioBuffer

Nir Soffer nsoffer at redhat.com
Sat Jan 29 23:33:28 UTC 2022


Improve AioBuffer to make it safer, easier to use, and faster when integrating
with other Go APIs.

New Go specific APIs:

- MakeAioBufferZero() - creates a new buffer using calloc(), to make it easy
  and efficient to use a zeroed buffer.

- AioBuffer.Slice() - create a slice backed by the underlying buffer without
  copying the contents of the buffer.

Performance improments:

- FromBytes() is 3 time faster
- Code using Bytes() should use Slice() now. aio_copy example shows up to 260%
  speedup.

Improve testing:

- New AioBuffer tests
- New AioBuffer benchmarks

Documention:

- AioBuffer is fully documnted now.

Nir Soffer (9):
  golang: tests: Add test for AioBuffer
  golang: aio_buffer.go: Make it safer to use
  golang: aio_buffer.go: Add missing documentation
  golang: aio_buffer.go: Add MakeAioBufferZero()
  golang: aio_buffer.go: Add Slice()
  golang: tests: Use AioBuffer.Slice()
  golang: aio_buffer.go: Speed up FromBytes()
  golang: aio_buffer.go: Benchmark copy flows
  golang: examples: aio_copy: Simplify using AioBuffer

 golang/Makefile.am                   |   1 +
 golang/aio_buffer.go                 |  39 ++++-
 golang/examples/aio_copy/aio_copy.go |  29 +---
 golang/libnbd_500_aio_pread_test.go  |   2 +-
 golang/libnbd_510_aio_pwrite_test.go |   8 +-
 golang/libnbd_620_aio_buffer_test.go | 236 +++++++++++++++++++++++++++
 6 files changed, 281 insertions(+), 34 deletions(-)
 create mode 100644 golang/libnbd_620_aio_buffer_test.go

-- 
2.34.1





More information about the Libguestfs mailing list