Check if we have it - if we do, add a 1MB buffer for the file
output. This further speeds up the log writing.
Signed-off-by: Jens Axboe <axboe@fb.com>
fi
echo "Rados Block Device engine $rbd"
fi
echo "Rados Block Device engine $rbd"
+##########################################
+# Check whether we have setvbuf
+setvbuf="no"
+cat > $TMPC << EOF
+#include <stdio.h>
+int main(int argc, char **argv)
+{
+ FILE *f = NULL;
+ char buf[80];
+ setvbuf(f, buf, _IOFBF, sizeof(buf));
+ return 0;
+}
+EOF
+if compile_prog "" "" "setvbuf"; then
+ setvbuf="yes"
+fi
+echo "setvbuf $setvbuf"
#############################################################################
#############################################################################
if test "$cpu_count" = "yes" ; then
output_sym "CONFIG_CPU_COUNT"
fi
if test "$cpu_count" = "yes" ; then
output_sym "CONFIG_CPU_COUNT"
fi
+if test "$setvbuf" = "yes" ; then
+ output_sym "CONFIG_SETVBUF"
+fi
echo "LIBS+=$LIBS" >> $config_host_mak
echo "CFLAGS+=$CFLAGS" >> $config_host_mak
echo "LIBS+=$LIBS" >> $config_host_mak
echo "CFLAGS+=$CFLAGS" >> $config_host_mak
+#ifdef CONFIG_SETVBUF
+static void *set_file_buffer(FILE *f)
+{
+ size_t size = 1048576;
+ void *buf;
+
+ buf = malloc(size);
+ setvbuf(f, buf, _IOFBF, size);
+ return buf;
+}
+
+static void clear_file_buffer(void *buf)
+{
+ free(buf);
+}
+#else
+static void *set_file_buffer(FILE *f)
+{
+ return NULL;
+}
+
+static void clear_file_buffer(void *buf)
+{
+}
+#endif
+
void __finish_log(struct io_log *log, const char *name)
{
unsigned int i;
void __finish_log(struct io_log *log, const char *name)
{
unsigned int i;
FILE *f;
f = fopen(name, "a");
FILE *f;
f = fopen(name, "a");
+ buf = set_file_buffer(f);
+
for (i = 0; i < log->nr_samples; i++) {
fprintf(f, "%lu, %lu, %u, %u\n",
(unsigned long) log->log[i].time,
for (i = 0; i < log->nr_samples; i++) {
fprintf(f, "%lu, %lu, %u, %u\n",
(unsigned long) log->log[i].time,
+ clear_file_buffer(buf);
free(log->log);
free(log);
}
free(log->log);
free(log);
}