Re: [Qemu-devel] [PATCH] Optimize screendump

2011-06-20 Thread Avi Kivity
On 06/19/2011 08:00 PM, Alexander Graf wrote: On 19.06.2011, at 18:04, Avi Kivity wrote: > On 06/19/2011 06:53 PM, Andreas Färber wrote: >> Am 19.06.2011 um 17:46 schrieb Avi Kivity: >> >>> On 06/19/2011 06:22 PM, Stefan Hajnoczi wrote: I wonder if this will break non-Linux platforms.

Re: [Qemu-devel] [PATCH] Optimize screendump

2011-06-19 Thread Alexander Graf
On 19.06.2011, at 18:04, Avi Kivity wrote: > On 06/19/2011 06:53 PM, Andreas Färber wrote: >> Am 19.06.2011 um 17:46 schrieb Avi Kivity: >> >>> On 06/19/2011 06:22 PM, Stefan Hajnoczi wrote: I wonder if this will break non-Linux platforms. Perhaps buffer an entire row of pixels instea

Re: [Qemu-devel] [PATCH] Optimize screendump

2011-06-19 Thread Avi Kivity
On 06/19/2011 06:53 PM, Andreas Färber wrote: Am 19.06.2011 um 17:46 schrieb Avi Kivity: On 06/19/2011 06:22 PM, Stefan Hajnoczi wrote: I wonder if this will break non-Linux platforms. Perhaps buffer an entire row of pixels instead and only fwrite(3) at the end of the outer loop. That's how

Re: [Qemu-devel] [PATCH] Optimize screendump

2011-06-19 Thread Andreas Färber
Am 19.06.2011 um 17:46 schrieb Avi Kivity: On 06/19/2011 06:22 PM, Stefan Hajnoczi wrote: I wonder if this will break non-Linux platforms. Perhaps buffer an entire row of pixels instead and only fwrite(3) at the end of the outer loop. That's how I wrote this in the first place. Since the co

Re: [Qemu-devel] [PATCH] Optimize screendump

2011-06-19 Thread Avi Kivity
On 06/19/2011 06:22 PM, Stefan Hajnoczi wrote: I wonder if this will break non-Linux platforms. Perhaps buffer an entire row of pixels instead and only fwrite(3) at the end of the outer loop. That's how I wrote this in the first place. Since the consensus is against these functions, I'll sub

Re: [Qemu-devel] [PATCH] Optimize screendump

2011-06-19 Thread Stefan Hajnoczi
On Sun, Jun 19, 2011 at 3:54 PM, Avi Kivity wrote: > When running kvm-autotest, fputc() is often the second highest (sometimes #1) > function showing up in a profile.  This is due to fputc() locking the file > for every byte written. > > Optimize by using fputc_unlocked().  Since the file is local

Re: [Qemu-devel] [PATCH] Optimize screendump

2011-06-19 Thread malc
On Sun, 19 Jun 2011, Avi Kivity wrote: CONFORMING TO The four functionsgetc_unlocked(), getchar_unlocked(), putc_unlocked(), putchar_unlocked() are in POSIX.1-2001. The non-standard *_unlocked() variants occur on a few Unix systems, and are available in rece

[Qemu-devel] [PATCH] Optimize screendump

2011-06-19 Thread Avi Kivity
When running kvm-autotest, fputc() is often the second highest (sometimes #1) function showing up in a profile. This is due to fputc() locking the file for every byte written. Optimize by using fputc_unlocked(). Since the file is local to the caller, clearly no locking is needed. According to t