diff options
author | dwight <dwight@10gen.com> | 2011-02-05 14:17:48 -0500 |
---|---|---|
committer | dwight <dwight@10gen.com> | 2011-02-05 14:17:48 -0500 |
commit | c823d631683873855a79f99f3c5bc11c09c7e188 (patch) | |
tree | db8a62485c47897732376a875953f6478798909f | |
parent | 4bee09a92063b273b54e77fc2930766caf4d79fc (diff) | |
download | mongo-c823d631683873855a79f99f3c5bc11c09c7e188.tar.gz |
nicer latency test admin command
-rw-r--r-- | db/dbcommands_admin.cpp | 13 | ||||
-rw-r--r-- | db/dur_journal.cpp | 26 |
2 files changed, 24 insertions, 15 deletions
diff --git a/db/dbcommands_admin.cpp b/db/dbcommands_admin.cpp index 6a8bbed9db1..ad77c66ce59 100644 --- a/db/dbcommands_admin.cpp +++ b/db/dbcommands_admin.cpp @@ -91,7 +91,8 @@ namespace mongo { } catch(...) { } - { + BSONObjBuilder bb[2]; + for( int pass = 0; pass < 2; pass++ ) { LogFile f(p.string()); AlignedBuilder b(1024 * 1024); { @@ -99,7 +100,7 @@ namespace mongo { for( int i = 0 ; i < 100; i++ ) { f.synchronousAppend(b.buf(), 8192); } - result.append("timeMillis8KB", t.millis() / 100.0); + bb[pass].append("8KB", t.millis() / 100.0); } { const int N = 50; @@ -113,16 +114,19 @@ namespace mongo { } long long y = t2.micros() - 4*N*1000; // not really trusting the timer granularity on all platforms so whichever is higher of x and y - result.append("timeMillis8KBWithPauses", max(x,y) / (N*1000.0)); + bb[pass].append("8KBWithPauses", max(x,y) / (N*1000.0)); } { Timer t; for( int i = 0 ; i < 20; i++ ) { f.synchronousAppend(b.buf(), 1024 * 1024); } - result.append("timeMillis1MB", t.millis() / 20.0); + bb[pass].append("1MB", t.millis() / 20.0); } + // second time around, we are prealloced. } + result.append("timeMillis", bb[0].obj()); + result.append("timeMillisWithPrealloc", bb[1].obj()); try { remove(p); @@ -131,7 +135,6 @@ namespace mongo { return 1; } - } journalLatencyTestCmd; class ValidateCmd : public Command { diff --git a/db/dur_journal.cpp b/db/dur_journal.cpp index b625ecb45b4..404a2691ff7 100644 --- a/db/dur_journal.cpp +++ b/db/dur_journal.cpp @@ -183,18 +183,25 @@ namespace mongo { void journalCleanup() { j.cleanup(); } // throws + void preallocateFile(filesystem::path p, unsigned long long len) { + if( exists(p) ) + return; + + const unsigned BLKSZ = 1024 * 1024; + log() << "preallocating a journal file " << p.string() << endl; + LogFile f(p.string()); + AlignedBuilder b(BLKSZ); + for( unsigned long long x = 0; x < len; x += BLKSZ ) { + f.synchronousAppend(b.buf(), BLKSZ); + } + } + + // throws void _preallocateFiles() { for( int i = 0; i <= 2; i++ ) { string fn = str::stream() << "prealloc." << i; filesystem::path filepath = getJournalDir() / fn; - if( exists(filepath) ) - continue; - - const unsigned BLKSZ = 1024 * 1024; - log() << "preallocating a journal file " << filepath.string() << endl; - LogFile f(filepath.string()); - AlignedBuilder b(BLKSZ); unsigned long long limit = Journal::DataLimit; if( debug && i == 1 ) { // moving 32->64, the prealloc files would be short. that is "ok", but we want to exercise that @@ -203,11 +210,10 @@ namespace mongo { // work anyway. limit = 16 * 1024 * 1024; } - for( unsigned long long x = 0; x < limit; x += BLKSZ ) { - f.synchronousAppend(b.buf(), BLKSZ); - } + preallocateFile(filepath, limit); } } + void preallocateFiles() { try { _preallocateFiles(); |