From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:52060) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QYJOa-0001Ne-5D for qemu-devel@nongnu.org; Sun, 19 Jun 2011 10:54:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QYJOY-0006vc-U4 for qemu-devel@nongnu.org; Sun, 19 Jun 2011 10:54:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:62002) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QYJOY-0006vL-Ma for qemu-devel@nongnu.org; Sun, 19 Jun 2011 10:54:38 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p5JEsbFV013697 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 19 Jun 2011 10:54:37 -0400 Received: from cleopatra.tlv.redhat.com (cleopatra.tlv.redhat.com [10.35.255.11]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p5JEsam6020304 for ; Sun, 19 Jun 2011 10:54:36 -0400 From: Avi Kivity Date: Sun, 19 Jun 2011 17:54:33 +0300 Message-Id: <1308495273-23383-1-git-send-email-avi@redhat.com> Subject: [Qemu-devel] [PATCH] Optimize screendump List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org 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; -- 1.7.5.3