mirror of
https://github.com/mongodb/mongo.git
synced 2024-11-30 00:56:44 +01:00
more flushtest
This commit is contained in:
parent
a4c7aae14c
commit
b726cbeed5
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user