On Mon, Oct 10, 2011 at 09:42:51AM +0200, Paolo Bonzini wrote: > On 10/10/2011 01:56 AM, Michael S. Tsirkin wrote: > >qemu file currently always buffers up data before writing it out. > >At least for memory this is probably not a good idea: > >writing out to file would be cheaper. Let's do > >that if we can, which should be the common case. If we can't, buffer. > > > >Signed-off-by: Michael S. Tsirkin<m...@redhat.com> > > > >--- > > > >Completely untested, this is just thinking aloud. > >Shouldn't the below save us a data copy in the > >common case, helping speed up migration? > > The problem here is qemu_put_byte and friends, where the indirection > of a function call would probably slow things down. In the common > case, qemu_put_byte is called a lot and f->buf_index would not be > zero.
True, maybe the right thing to do is use a size cutoff, avoid a copy if buffer is large enough. I note the buffer in qemu file is 32K - is that based on some specific measurements or just a random large number? Any objections to making it smaller, like 4K? > The way to go would probably be to merge QEMUFile and > QEMUBufferedFile's two buffering layers, which also removes a copy. > > Paolo Yes, it does look sane. QEMUFile doesn't seem to ever be used without QEMUBufferedFile - is that true? -- MST