Received: from eggs.gnu.org ([140.186.70.92]:38076) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QYJZV-0002rE-6G for qemu-devel@nongnu.org; Sun, 19 Jun 2011 11:05:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QYJZU-0000Rl-7y for qemu-devel@nongnu.org; Sun, 19 Jun 2011 11:05:57 -0400 Received: from fe01x03-cgp.akado.ru ([77.232.31.164]:59436 helo=akado.ru) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QYJZU-0000RW-1l for qemu-devel@nongnu.org; Sun, 19 Jun 2011 11:05:56 -0400 Date: Sun, 19 Jun 2011 19:05:28 +0400 (MSD) From: malc In-Reply-To: <1308495273-23383-1-git-send-email-avi@redhat.com> Message-ID: References: <1308495273-23383-1-git-send-email-avi@redhat.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Subject: Re: [Qemu-devel] [PATCH] Optimize screendump List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Avi Kivity Cc: qemu-devel@nongnu.org On Sun, 19 Jun 2011, Avi Kivity wrote: CONFORMING TO The four functions getc_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 recent glibc. They should probably not be used. > 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 the manual, _GNU_SOURCE is all > that's needed for the function to be present. > > Signed-off-by: Avi Kivity > --- > hw/vga.c | 6 +++--- > 1 files changed, 3 insertions(+), 3 deletions(-) > > diff --git a/hw/vga.c b/hw/vga.c > index d5bc582..8b63358 100644 > --- a/hw/vga.c > +++ b/hw/vga.c > @@ -2369,9 +2369,9 @@ int ppm_save(const char *filename, struct DisplaySurface *ds) > (ds->pf.gmax + 1); > b = ((v >> ds->pf.bshift) & ds->pf.bmax) * 256 / > (ds->pf.bmax + 1); > - fputc(r, f); > - fputc(g, f); > - fputc(b, f); > + fputc_unlocked(r, f); > + fputc_unlocked(g, f); > + fputc_unlocked(b, f); > d += ds->pf.bytes_per_pixel; > } > d1 += ds->linesize; > -- mailto:av1474@comtv.ru