[Libguestfs] [libnbd PATCH] python: Allow control over copy/share of nbd.Buffer

Eric Blake eblake at redhat.com
Tue Jun 21 19:27:44 UTC 2022


On Tue, Jun 14, 2022 at 03:39:40PM +0100, Richard W.M. Jones wrote:
> On Tue, Jun 14, 2022 at 07:58:08AM -0500, Eric Blake wrote:
> > Add new methods nbd.Buffer.{to,from}_buffer that avoid the copying
> > present in the existing nbd.Buffer.{to,from}_bytearray.  The reduction
> > in copies possible by this approach is no longer quite as necessary,
> > now that aio_p{read,write} have been converted to take buffers
> > directly.  However, there is still one (marginal) benefit: if you use
> > h.set_pread_initialize(False), and create a new buffer for every I/O
> > (rather than reusing a buffer pool), nbd.Buffer(n) handed to
> > h.aio_pread then buf.to_buffer() is slightly faster than handing a
> > bytearray(n) directly to h.aio_pread, because we are able to skip the
> > step of pre-zeroing the buffer.
> > ---
> > 

> 
> Acked-by: Richard W.M. Jones <rjones at redhat.com>
> 
> Rich.

Now in as commit 5b74b04

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


More information about the Libguestfs mailing list