diff --git a/src/writer.cpp b/src/writer.cpp index c440b0ac5..5a00d774d 100644 --- a/src/writer.cpp +++ b/src/writer.cpp @@ -123,8 +123,10 @@ int WriteWorker::WaitForCallbacks(MDB_txn** txn, bool allowCommit, uint32_t* tar uint64_t start; unsigned int envFlags; mdb_env_get_flags(env, &envFlags); +#ifdef MDB_TRACK_METRICS if (envFlags & MDB_TRACK_METRICS) start = get_time64(); +#endif if (target) { uint64_t delay = 1; do { @@ -132,8 +134,10 @@ int WriteWorker::WaitForCallbacks(MDB_txn** txn, bool allowCommit, uint32_t* tar delay = delay << 1ll; if ((*target & 0xf) || (allowCommit && finishedProgress)) { // we are in position to continue writing or commit, so forward progress can be made without interrupting yet +#ifdef MDB_TRACK_METRICS if (envFlags & MDB_TRACK_METRICS) envForTxn->timeTxnWaiting += get_time64() - start; +#endif interruptionStatus = 0; return 0; } @@ -141,8 +145,10 @@ int WriteWorker::WaitForCallbacks(MDB_txn** txn, bool allowCommit, uint32_t* tar } else { pthread_cond_wait(envForTxn->writingCond, envForTxn->writingLock); } +#ifdef MDB_TRACK_METRICS if (envFlags & MDB_TRACK_METRICS) envForTxn->timeTxnWaiting += get_time64() - start; +#endif if (interruptionStatus == INTERRUPT_BATCH) { // interrupted by JS code that wants to run a synchronous transaction interruptionStatus = RESTART_WORKER_TXN; rc = mdb_txn_commit(*txn);