[svn:parrot] r39450 - branches/io_rewiring/src/io
Infinoid at svn.parrot.org
Infinoid at svn.parrot.org
Mon Jun 8 13:22:32 UTC 2009
Author: Infinoid
Date: Mon Jun 8 13:22:31 2009
New Revision: 39450
URL: https://trac.parrot.org/parrot/changeset/39450
Log:
We really don't need to call fsync() after every write().
Several functions in src/io/buffer.c would call Parrot_io_flush() to
write buffered but unwritten data. The problem is, that would also
call PIO_FLUSH(), forcing the OS to push the data all the way to disk.
While OS-level flushes are useful, we don't want to do them all the
time, as doing so severely hurts performance. Ensuring disk consistency
wasn't part of the contract of these functions anyway, they were just
doing it to make the buffer pointers and lengths consistent so they could
do their jobs. If we call Parrot_io_flush_buffer() directly instead of
Parrot_io_flush(), we write out the buffered data, but don't call the OS
flush, so life is good.
Removing the OS flush sped up "coretest" by a factor of 2, for chromatic.
Apparently my Thinkpad's disk is slower than his, so the difference is
even more striking for me:
before: make coretest 84.97s user 61.91s system 32% cpu 7:35.52 total
after : make coretest 75.22s user 43.93s system 67% cpu 2:57.62 total
Modified:
branches/io_rewiring/src/io/buffer.c
Modified: branches/io_rewiring/src/io/buffer.c
==============================================================================
--- branches/io_rewiring/src/io/buffer.c Mon Jun 8 09:10:08 2009 (r39449)
+++ branches/io_rewiring/src/io/buffer.c Mon Jun 8 13:22:31 2009 (r39450)
@@ -79,7 +79,7 @@
/* If there is already a buffer, make sure we flush before modifying it. */
if (buffer_start)
- Parrot_io_flush(interp, filehandle);
+ Parrot_io_flush_buffer(interp, filehandle);
/* Choose an appropriate buffer size for caller */
switch (bufsize) {
@@ -286,7 +286,7 @@
/* write buffer flush */
if (buffer_flags & PIO_BF_WRITEBUF) {
- Parrot_io_flush(interp, filehandle);
+ Parrot_io_flush_buffer(interp, filehandle);
buffer_flags = Parrot_io_get_buffer_flags(interp, filehandle);
}
@@ -416,7 +416,7 @@
/* write buffer flush */
if (buffer_flags & PIO_BF_WRITEBUF) {
- Parrot_io_flush(interp, filehandle);
+ Parrot_io_flush_buffer(interp, filehandle);
buffer_flags = Parrot_io_get_buffer_flags(interp, filehandle);
}
@@ -623,7 +623,7 @@
long wrote;
/* Write through, skip buffer. */
- Parrot_io_flush(interp, filehandle);
+ Parrot_io_flush_buffer(interp, filehandle);
wrote = PIO_WRITE(interp, filehandle, s);
if (wrote == (long)len) {
@@ -658,7 +658,7 @@
Parrot_io_set_buffer_next(interp, filehandle, buffer_next);
Parrot_io_set_file_position(interp, filehandle, (avail +
Parrot_io_get_file_position(interp, filehandle)));
- Parrot_io_flush(interp, filehandle);
+ Parrot_io_flush_buffer(interp, filehandle);
buffer_flags |= PIO_BF_WRITEBUF;
Parrot_io_set_buffer_flags(interp, filehandle, buffer_flags);
@@ -718,7 +718,7 @@
if ((newpos < file_pos - (buffer_next - buffer_start))
|| (newpos >= file_pos + (buffer_end - buffer_next))) {
- Parrot_io_flush(interp, filehandle);
+ Parrot_io_flush_buffer(interp, filehandle);
newpos = PIO_SEEK(interp, filehandle, newpos, SEEK_SET);
}
else {
More information about the parrot-commits
mailing list