Permalink
Browse files

prefetch type stuff

  • Loading branch information...
1 parent b1a6274 commit 81fece68e9b0f1723b9c5d2e468fd2e43794022d @dwight dwight committed Jul 15, 2011
View
@@ -172,7 +172,7 @@ namespace mongo {
}
inline BSONObj BSONElement::embeddedObjectUserCheck() const {
- if ( isABSONObj() )
+ MONGOIF ( isABSONObj() )
return BSONObj(value());
stringstream ss;
ss << "invalid parameter: expected an object (" << fieldName() << ")";
View
@@ -37,7 +37,7 @@ namespace mongo {
*/
BSONObjIterator(const BSONObj& jso) {
int sz = jso.objsize();
- if ( sz == 0 ) {
+ MONGO_IF ( sz == 0 ) {
_pos = _theend = 0;
return;
}
View
@@ -31,6 +31,7 @@
#endif
+namespace mongo {
/* Note: do not clutter code with these -- ONLY use in hot spots / significant loops. */
@@ -42,13 +43,23 @@
// branch prediction. indicate we expect to not enter the if statement body
# define MONGO_IF(x) if( (x) )
-// prefetch data from memory
-# define MONGOPREFETCH(x) { /*just check we compile:*/ assert(sizeof(*x)); }
+# if defined(_WIN32)
+ // prefetch data from memory
+ inline void prefetch(const void *p) {
+ _mm_prefetch((char *) p, _MM_HINT_T0);
+ }
+#else
+ inline void prefetch(void *p) { }
+#endif
#else
# define MONGOIF(x) if( __builtin_expect((x), 1) )
# define MONGO_IF(x) if( __builtin_expect((x), 0) )
-# define MONGOPREFETCH(x) { /*just check we compile:*/ assert(sizeof(*x)); }
+
+ inline void prefetch(void *p) {
+ }
#endif
+
+}
View
@@ -123,7 +123,6 @@ namespace mongo {
for( set<WriteIntent>::iterator i = commitJob.writes().begin(); i != commitJob.writes().end(); i++ ) {
prepBasicWrite_inlock(bb, &(*i), lastDbPath);
}
-
}
void resetLogBuffer(AlignedBuilder& bb) {
View
@@ -36,6 +36,7 @@
#include "../lasterror.h"
#include "../../s/d_logic.h"
#include "../repl_block.h"
+#include "server.h"
namespace mongo {
Binary file not shown.
View
@@ -0,0 +1,26 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test", "test.vcxproj", "{215B2D68-0A70-4D10-8E75-B33010C62A91}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Debug|x64 = Debug|x64
+ Release|Win32 = Release|Win32
+ Release|x64 = Release|x64
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {215B2D68-0A70-4D10-8E75-B33010C62A91}.Debug|Win32.ActiveCfg = Debug|Win32
+ {215B2D68-0A70-4D10-8E75-B33010C62A91}.Debug|Win32.Build.0 = Debug|Win32
+ {215B2D68-0A70-4D10-8E75-B33010C62A91}.Debug|x64.ActiveCfg = Debug|x64
+ {215B2D68-0A70-4D10-8E75-B33010C62A91}.Debug|x64.Build.0 = Debug|x64
+ {215B2D68-0A70-4D10-8E75-B33010C62A91}.Release|Win32.ActiveCfg = Release|Win32
+ {215B2D68-0A70-4D10-8E75-B33010C62A91}.Release|Win32.Build.0 = Release|Win32
+ {215B2D68-0A70-4D10-8E75-B33010C62A91}.Release|x64.ActiveCfg = Release|x64
+ {215B2D68-0A70-4D10-8E75-B33010C62A91}.Release|x64.Build.0 = Release|x64
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
View
No changes.
@@ -0,0 +1,36 @@
+// BUG: [SERVER-1768] replica set getlasterror {w: 2} after 2000
+// inserts hangs while secondary servers log "replSet error RS102 too stale to catch up" every once in a while
+
+function newReplicaSet (name, numServers) {
+ var rs = new ReplSetTest({name: name, nodes: numServers})
+ rs.startSet()
+ rs.initiate()
+ rs.awaitReplication()
+ return rs
+}
+
+function go() {
+var N = 2000
+
+// ~1KB string
+var Text = ''
+for (var i = 0; i < 40; i++)
+ Text += 'abcdefghijklmnopqrstuvwxyz'
+
+// Create replica set of 3 servers
+var repset = newReplicaSet('repset', 3)
+var conn = repset.getMaster()
+var db = conn.getDB('test')
+
+// Add data to it
+for (var i = 0; i < N; i++)
+ db['foo'].insert({x: i, text: Text})
+
+// wait to be copied to at least one secondary (BUG hangs here)
+db.getLastError(2)
+
+print('getlasterror_w2.js SUCCESS')
+}
+
+// turn off until fixed
+//go();
View
@@ -19,5 +19,3 @@
// branch prediction. indicate we expect to not enter the if statement body
#define _IF MONGO_IF
-// prefetch data from memory
-#define PREFETCH MONGOPREFETCH
Binary file not shown.
View
@@ -0,0 +1,13 @@
+t = db.fooo;
+t.drop();
+x = { str:'aaaabbbbcc' }
+s = new Date();
+for( var i = 0; i < 100000; i++ ) {
+ x.i = i;
+ t.insert(x);
+}
+print( (new Date())-s );
+t.ensureIndex({x:1});
+t.ensureIndex({str:1});
+print( (new Date())-s );
+
View
BIN test.pgd
Binary file not shown.

0 comments on commit 81fece6

Please sign in to comment.