diff options
author | yellow <yellow@10gen.com> | 2009-01-04 19:13:51 +0000 |
---|---|---|
committer | yellow <yellow@10gen.com> | 2009-01-04 19:13:51 +0000 |
commit | b726cbeed57f1242defe4780b4a7c21159916986 (patch) | |
tree | fa3f6996baac21d3e57e773c6a34432324914aae /db/flushtest.cpp | |
parent | a4c7aae14c910a0c8785fce6d771d0d2475e81d7 (diff) | |
download | mongo-b726cbeed57f1242defe4780b4a7c21159916986.tar.gz |
more flushtest
Diffstat (limited to 'db/flushtest.cpp')
-rw-r--r-- | db/flushtest.cpp | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/db/flushtest.cpp b/db/flushtest.cpp index 3a4e9c16c13..41a49e6ab74 100644 --- a/db/flushtest.cpp +++ b/db/flushtest.cpp @@ -35,7 +35,7 @@ int main(int argc, char* argv[], char *envp[] ) { for( int i = 0; i < 10000; i++ ) { fwrite("abc", 3, 1, f); fflush(f); - fsync( fileno( f ) ); + fsync( fileno( f ) ); } int ms = t.millis(); cout << "flush: " << ms << "ms, " << ms / 10000.0 << "ms/request" << endl; @@ -46,11 +46,11 @@ int main(int argc, char* argv[], char *envp[] ) { for( int i = 0; i < 500; i++ ) { fwrite("abc", 3, 1, f); fflush(f); - fsync( fileno( f ) ); - sleepmillis(10); + fsync( fileno( f ) ); + sleepmillis(2); } - int ms = t.millis(); - cout << "flush with sleeps intermixed: " << ms << "ms, " << (ms-5000) / 500.0 << "ms/request" << endl; + int ms = t.millis() - 500 * 2; + cout << "flush with sleeps: " << ms << "ms, " << ms / 500.0 << "ms/request" << endl; } char buf[8192]; @@ -82,14 +82,14 @@ int main(int argc, char* argv[], char *envp[] ) { buf[0]++; fflush(f); fullsync(fileno(f)); - sleepmillis(10); + sleepmillis(2); } - int ms = t.millis(); - cout << "fullsync with sleeps intermixed: " << ms << "ms, " << (ms-5000) / 500.0 << "ms/request" << endl; + int ms = t.millis() - 2 * 500; + cout << "fullsync with sleeps: " << ms << "ms, " << ms / 500.0 << "ms/request" << endl; } } - // with noatime + // without growing { fclose(f); /* try from beginning of the file, where we aren't appending and changing the file length, @@ -106,6 +106,25 @@ int main(int argc, char* argv[], char *envp[] ) { int ms = t.millis(); cout << "fullsync without growing: " << ms << "ms, " << ms / ((double) n) << "ms/request" << endl; } + + // without growing, with delay + { + fclose(f); + /* try from beginning of the file, where we aren't appending and changing the file length, + to see if this is faster as the directory entry then doesn't have to be flushed (if noatime in effect). + */ + f = fopen("/data/db/temptest", "r+"); + Timer t; + int n = 500; + for( int i = 0; i < n; i++ ) { + fwrite("xyz", 3, 1, f); + fflush(f); + fullsync(fileno(f)); + sleepmillis(2); + } + int ms = t.millis() - 2 * 500; + cout << "fullsync without growing with sleeps: " << ms << "ms, " << ms / ((double) n) << "ms/request" << endl; + } return 0; } |