> > On Sat, Nov 23, 2019 at 06:11:47PM +0200, Nir Soffer wrote: > > > There is performance implication for v1 plugins like rhv-upload-plugin > > that > > > need to copy the bytes from imageio server on python side: > > > > > > r = http.getresponse() > > > ... > > > return bytearray(r.read()) > > > > > > This is sad because on the C side we mempcpy the data again. So with > > this patch > > > we avoid one copy of the two. > > > > > > To avoid all unneeded copies, we need to change pread() to: > > > > > > def pread(h, buf, offset): > > > > > > So the python side we can do: > > > > > > f.readinto(buf) > > > > > > Or: > > > > > > sock.recv_info(buf) > > > > > > It does not work for HTTPResponse, so in this case we have to do: > > > > > > buf[:] = r.read() > > > > > > Since we work on v2 now, I think we should consider this change. > > > > Right, we can consider this for v2, while leaving v1 callers alone. > > > > > An uglier alternative is: > > > > > > def preadinto(h, buf, offset): > > > > > > Matching python read() and readinto() interface.
So if I'm understand this correctly, is it true that Python would be writing directly to the C buffer allocated by nbdkit? This sounds like it would be beneficial. Would you like to do a patch for this? For v2 it's fine to just have: def pread(h, buf, offset) since that is the same as the C API. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://people.redhat.com/~rjones/virt-df/ _______________________________________________ Libguestfs mailing list [email protected] https://www.redhat.com/mailman/listinfo/libguestfs
