Change default db-sync-mode to fast, not fastest

This commit is contained in:
Howard Chu 2016-08-28 12:07:00 +01:00
parent a569b264bc
commit dc411ea3b7
1 changed files with 14 additions and 13 deletions

View File

@ -293,20 +293,23 @@ namespace cryptonote
catch (...) { } catch (...) { }
BlockchainDB* db = nullptr; BlockchainDB* db = nullptr;
uint64_t BDB_FAST_MODE = 0; uint64_t DBS_FAST_MODE = 0;
uint64_t BDB_FASTEST_MODE = 0; uint64_t DBS_FASTEST_MODE = 0;
uint64_t BDB_SAFE_MODE = 0; uint64_t DBS_SAFE_MODE = 0;
if (db_type == "lmdb") if (db_type == "lmdb")
{ {
db = new BlockchainLMDB(); db = new BlockchainLMDB();
DBS_SAFE_MODE = MDB_NORDAHEAD;
DBS_FAST_MODE = MDB_NORDAHEAD | MDB_NOSYNC;
DBS_FASTEST_MODE = MDB_NORDAHEAD | MDB_NOSYNC | MDB_WRITEMAP | MDB_MAPASYNC;
} }
else if (db_type == "berkeley") else if (db_type == "berkeley")
{ {
#if defined(BERKELEY_DB) #if defined(BERKELEY_DB)
db = new BlockchainBDB(); db = new BlockchainBDB();
BDB_FAST_MODE = DB_TXN_WRITE_NOSYNC; DBS_FAST_MODE = DB_TXN_WRITE_NOSYNC;
BDB_FASTEST_MODE = DB_TXN_NOSYNC; DBS_FASTEST_MODE = DB_TXN_NOSYNC;
BDB_SAFE_MODE = DB_TXN_SYNC; DBS_SAFE_MODE = DB_TXN_SYNC;
#else #else
LOG_ERROR("BerkeleyDB support disabled."); LOG_ERROR("BerkeleyDB support disabled.");
return false; return false;
@ -329,7 +332,6 @@ namespace cryptonote
try try
{ {
uint64_t db_flags = 0; uint64_t db_flags = 0;
bool islmdb = db_type == "lmdb";
std::vector<std::string> options; std::vector<std::string> options;
boost::trim(db_sync_mode); boost::trim(db_sync_mode);
@ -338,9 +340,8 @@ namespace cryptonote
for(const auto &option : options) for(const auto &option : options)
LOG_PRINT_L0("option: " << option); LOG_PRINT_L0("option: " << option);
// temporarily default to fastest:async:1000 // default to fast:async:1000
uint64_t DEFAULT_FLAGS = islmdb ? MDB_WRITEMAP | MDB_MAPASYNC | MDB_NORDAHEAD | MDB_NOMETASYNC | MDB_NOSYNC : uint64_t DEFAULT_FLAGS = DBS_FAST_MODE;
BDB_FASTEST_MODE;
if(options.size() == 0) if(options.size() == 0)
{ {
@ -354,13 +355,13 @@ namespace cryptonote
if(options[0] == "safe") if(options[0] == "safe")
{ {
safemode = true; safemode = true;
db_flags = islmdb ? MDB_NORDAHEAD : BDB_SAFE_MODE; db_flags = DBS_SAFE_MODE;
sync_mode = db_nosync; sync_mode = db_nosync;
} }
else if(options[0] == "fast") else if(options[0] == "fast")
db_flags = islmdb ? MDB_NOMETASYNC | MDB_NOSYNC | MDB_NORDAHEAD : BDB_FAST_MODE; db_flags = DBS_FAST_MODE;
else if(options[0] == "fastest") else if(options[0] == "fastest")
db_flags = islmdb ? MDB_WRITEMAP | MDB_MAPASYNC | MDB_NORDAHEAD | MDB_NOMETASYNC | MDB_NOSYNC : BDB_FASTEST_MODE; db_flags = DBS_FASTEST_MODE;
else else
db_flags = DEFAULT_FLAGS; db_flags = DEFAULT_FLAGS;
} }