diff options
author | Dwight <dmerriman@gmail.com> | 2009-02-03 17:39:44 -0500 |
---|---|---|
committer | Dwight <dmerriman@gmail.com> | 2009-02-03 17:39:44 -0500 |
commit | aca3431dbf4830c4164ca5e9e01819ecf174671a (patch) | |
tree | c61954af25337dbd35329fbbcb18af3eb1d94c3b /db | |
parent | 57dac9f774f668742bf289c84ce9548cfe627065 (diff) | |
download | mongo-aca3431dbf4830c4164ca5e9e01819ecf174671a.tar.gz |
defer reccache writes
Diffstat (limited to 'db')
-rw-r--r-- | db/reccache.h | 4 | ||||
-rw-r--r-- | db/storage.cpp | 12 |
2 files changed, 9 insertions, 7 deletions
diff --git a/db/reccache.h b/db/reccache.h index 7c0ea355088..cc2c33ab174 100644 --- a/db/reccache.h +++ b/db/reccache.h @@ -17,7 +17,7 @@ class RecCache { };
unsigned recsize;
map<DiskLoc, Node*> m;
- list<DiskLoc> dirtyl;
+ set<DiskLoc> dirtyl;
Node *newest, *oldest;
unsigned nnodes;
public:
@@ -68,7 +68,7 @@ public: Node *n = i->second;
if( !n->dirty ) {
n->dirty = true;
- dirtyl.push_back(n->loc);
+ dirtyl.insert(n->loc);
}
}
}
diff --git a/db/storage.cpp b/db/storage.cpp index cbf9767a0b9..a1158f32b2a 100644 --- a/db/storage.cpp +++ b/db/storage.cpp @@ -12,8 +12,9 @@ BasicRecStore RecCache::tempStore; RecCache BasicCached_RecStore::rc(BucketSize); static void storeThread() {
+ massert("not using", false);
while( 1 ) {
- sleepsecs(1);
+ sleepsecs(100);
dblock lk;
BasicCached_RecStore::rc.writeDirty();
RecCache::tempStore.flush();
@@ -55,7 +56,7 @@ void BasicRecStore::init(const char *fn, unsigned recsize) writeHeader();
}
f.flush();
- boost::thread t(storeThread);
+ // boost::thread t(storeThread);
}
inline void RecCache::writeIfDirty(Node *n) {
@@ -65,9 +66,10 @@ inline void RecCache::writeIfDirty(Node *n) { }
}
+/* note that this is written in order, as much as possible, given that dirtyl is of type set. */
void RecCache::writeDirty() {
try {
- for( list<DiskLoc>::iterator i = dirtyl.begin(); i != dirtyl.end(); i++ ) {
+ for( set<DiskLoc>::iterator i = dirtyl.begin(); i != dirtyl.end(); i++ ) {
map<DiskLoc, Node*>::iterator j = m.find(*i);
if( j != m.end() )
writeIfDirty(j->second);
@@ -79,8 +81,8 @@ void RecCache::writeDirty() { dirtyl.clear();
}
-// 10k * 8KB = 80MB
-const unsigned RECCACHELIMIT = 10000;
+// 100k * 8KB = 800MB
+const unsigned RECCACHELIMIT = 150000;
inline void RecCache::ejectOld() {
if( nnodes <= RECCACHELIMIT )
|