From: Ben Pfaff Date: Sat, 7 May 2011 20:01:02 +0000 (-0700) Subject: temp-file: Use 64 kB buffer for temporary files. X-Git-Tag: v0.7.9~313 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ddc91d774720aceb968939b57692d144daf9f6a7;p=pspp-builds.git temp-file: Use 64 kB buffer for temporary files. Generally PSPP uses temporary files because it has a lot of data to write to them. The default glibc buffer is only 4 kB. In my tests using a 64 kB reduced runtime from 2.5 seconds to 2.0 seconds, but increasing the buffer to 1 MB had no additional effect, so 64 kB is a reasonable choice. Bug #33260. --- diff --git a/src/libpspp/temp-file.c b/src/libpspp/temp-file.c index c1ffbea6..ffd5da7c 100644 --- a/src/libpspp/temp-file.c +++ b/src/libpspp/temp-file.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 2010 Free Software Foundation, Inc. + Copyright (C) 2010, 2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -56,6 +56,8 @@ create_temp_file (void) file_name = xasprintf ("%s/%d", temp_dir->dir_name, idx++); stream = fopen_temp (file_name, "wb+"); + if (stream != NULL) + setvbuf (stream, NULL, _IOFBF, 65536); free (file_name); return stream;