From 03c945d27cd374ba32252fb9770d80d7b1b05a41 Mon Sep 17 00:00:00 2001 From: Kris Zyp Date: Wed, 21 Feb 2024 10:36:22 -0700 Subject: [PATCH] Using compiler conditional to avoid referencing newer flag, #267, #273 --- src/writer.cpp | 6 ++++++ 1 file changed, 6 insertions(+) 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);