Skip to content

Commit

Permalink
dur once prealloc is used keep using it
Browse files Browse the repository at this point in the history
  • Loading branch information
dwight committed Feb 6, 2011
1 parent 71ef504 commit 221dddb
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions db/dur_journal.cpp
Expand Up @@ -47,7 +47,7 @@ namespace mongo {
BOOST_STATIC_ASSERT( sizeof(JEntry) == 12 );
BOOST_STATIC_ASSERT( sizeof(LSNFile) == 88 );

bool _preallocateIsFaster = false;
bool usingPreallocate = false;

void removeOldJournalFile(path p);

Expand Down Expand Up @@ -248,20 +248,21 @@ namespace mongo {
}

void preallocateFiles() {
_preallocateIsFaster = preallocateIsFaster();
if( !_preallocateIsFaster )
return;

try {
_preallocateFiles();
}
catch(...) {
log() << "warning caught exception in preallocateFiles, continuing" << endl;
if( preallocateIsFaster() ||
exists(getJournalDir()/"prealloc.0") || // if enabled previously, keep using
exists(getJournalDir()/"prealloc.1") ) {
usingPreallocate = true;
try {
_preallocateFiles();
}
catch(...) {
log() << "warning caught exception in preallocateFiles, continuing" << endl;
}
}
}

void removeOldJournalFile(path p) {
if( _preallocateIsFaster ) {
if( usingPreallocate ) {
try {
for( int i = 0; i <= 2; i++ ) {
string fn = str::stream() << "prealloc." << i;
Expand Down

0 comments on commit 221dddb

Please sign in to comment.