summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathias Stearn <mathias@10gen.com>2016-05-02 11:36:17 -0400
committerMathias Stearn <mathias@10gen.com>2016-05-09 17:52:12 -0400
commit423ba14c79ab2749e8717cc36e4efdb204de9751 (patch)
tree167b05257ccda9f05f46ae29e390f21351750225
parent6cb108ba117f272f5a6db9cd99d4a5c30cc27d28 (diff)
downloadmongo-423ba14c79ab2749e8717cc36e4efdb204de9751.tar.gz
SERVER-24005 Use FastClockSource in getNextGlobalTimestamp()
This is called under a big global lock and is substantially faster on some systems.
-rw-r--r--src/mongo/db/SConscript1
-rw-r--r--src/mongo/db/global_timestamp.cpp6
-rw-r--r--src/mongo/db/ops/SConscript2
3 files changed, 8 insertions, 1 deletions
diff --git a/src/mongo/db/SConscript b/src/mongo/db/SConscript
index a4ef79cb40e..44acf010272 100644
--- a/src/mongo/db/SConscript
+++ b/src/mongo/db/SConscript
@@ -225,6 +225,7 @@ env.Library(
],
LIBDEPS=[
'$BUILD_DIR/mongo/base',
+ '$BUILD_DIR/mongo/db/service_context'
]
)
diff --git a/src/mongo/db/global_timestamp.cpp b/src/mongo/db/global_timestamp.cpp
index b096feda9cc..d380e2a4f05 100644
--- a/src/mongo/db/global_timestamp.cpp
+++ b/src/mongo/db/global_timestamp.cpp
@@ -29,8 +29,11 @@
#define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kDefault
#include "mongo/db/global_timestamp.h"
+#include "mongo/db/service_context.h"
#include "mongo/platform/atomic_word.h"
+#include "mongo/util/clock_source.h"
#include "mongo/util/log.h"
+#include "mongo/util/time_support.h"
namespace mongo {
namespace {
@@ -46,7 +49,8 @@ Timestamp getLastSetTimestamp() {
}
Timestamp getNextGlobalTimestamp() {
- const unsigned now = Date_t::now().toMillisSinceEpoch() / 1000;
+ const unsigned now = durationCount<Seconds>(
+ getGlobalServiceContext()->getFastClockSource()->now().toDurationSinceEpoch());
// Optimistic approach: just increment the timestamp, assuming the seconds still match.
auto next = globalTimestamp.addAndFetch(1);
diff --git a/src/mongo/db/ops/SConscript b/src/mongo/db/ops/SConscript
index e91110656a4..ab345cb238c 100644
--- a/src/mongo/db/ops/SConscript
+++ b/src/mongo/db/ops/SConscript
@@ -108,6 +108,7 @@ env.CppUnitTest(
source='modifier_current_date_test.cpp',
LIBDEPS=[
'$BUILD_DIR/mongo/bson/mutable/mutable_bson_test_utils',
+ '$BUILD_DIR/mongo/db/service_context_noop_init',
'update',
],
)
@@ -126,6 +127,7 @@ env.CppUnitTest(
source='modifier_object_replace_test.cpp',
LIBDEPS=[
'$BUILD_DIR/mongo/bson/mutable/mutable_bson_test_utils',
+ '$BUILD_DIR/mongo/db/service_context_noop_init',
'update',
],
)