From ddc91d774720aceb968939b57692d144daf9f6a7 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sat, 7 May 2011 13:01:02 -0700 Subject: [PATCH] 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. --- src/libpspp/temp-file.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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; -- 2.30.2