summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDwight <dmerriman@gmail.com>2008-06-10 13:13:05 -0400
committerDwight <dmerriman@gmail.com>2008-06-10 13:13:05 -0400
commit1aeaa4f34d9778b391f287542c0acb40daa21456 (patch)
tree5fb203350278f0dbe0b6731621c94dde327d06ea
parent4690479e3494686003317b6d98f0a4b705794a14 (diff)
downloadmongo-1aeaa4f34d9778b391f287542c0acb40daa21456.tar.gz
alloc cursor sl faster
-rw-r--r--db/clientcursor.cpp7
-rw-r--r--db/db.cpp2
-rw-r--r--stdafx.h2
3 files changed, 7 insertions, 4 deletions
diff --git a/db/clientcursor.cpp b/db/clientcursor.cpp
index d113bba9f78..2f409597eb4 100644
--- a/db/clientcursor.cpp
+++ b/db/clientcursor.cpp
@@ -86,14 +86,17 @@ void ClientCursor::updateLocation() {
c->noteLocation();
}
+int ctmLast = 0; // so we don't have to do find() which is a little slow very often.
long long ClientCursor::allocCursorId() {
long long x;
+ int ctm = (int) curTimeMillis();
while( 1 ) {
x = (((long long)rand()) << 32);
- x = x | (int) curTimeMillis() | 0x80000000; // OR to make sure not zero
- if( ClientCursor::find(x) == 0 )
+ x = x | ctm | 0x80000000; // OR to make sure not zero
+ if( ctm != ctmLast || ClientCursor::find(x) == 0 )
break;
}
+ ctmLast = ctm;
DEV cout << "alloccursorid " << x << endl;
return x;
}
diff --git a/db/db.cpp b/db/db.cpp
index 108e318e5d1..79cb4b5b810 100644
--- a/db/db.cpp
+++ b/db/db.cpp
@@ -274,7 +274,7 @@ public:
};
void listen(int port) {
- const char *Version = "db version: 112 6jun2008";
+ const char *Version = "db version: 113 10jun2008";
problem() << Version << endl;
cout << Version << endl;
pdfileInit();
diff --git a/stdafx.h b/stdafx.h
index 88204ce7da4..cc576e18bfa 100644
--- a/stdafx.h
+++ b/stdafx.h
@@ -99,7 +99,7 @@ inline ostream& problem() {
time_t t;
time(&t);
string now(ctime(&t),0,20);
- problems << "problem " << now;
+ problems << "~ " << now;
if( client )
problems << curNs << ' ';
return problems;