mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-20 05:28:21 +08:00
mdbx: avoid extra looping inside mdbx_env_info_ex()
.
This commit is contained in:
parent
839da86cac
commit
f4057b2c3b
28
src/core.c
28
src/core.c
@ -19540,20 +19540,17 @@ __cold static int fetch_envinfo_ex(const MDBX_env *env, const MDBX_txn *txn,
|
|||||||
#endif /* MDBX_ENABLE_PGOP_STAT*/
|
#endif /* MDBX_ENABLE_PGOP_STAT*/
|
||||||
}
|
}
|
||||||
|
|
||||||
arg->mi_self_latter_reader_txnid = arg->mi_latter_reader_txnid = 0;
|
arg->mi_self_latter_reader_txnid = arg->mi_latter_reader_txnid =
|
||||||
if (lck) {
|
arg->mi_recent_txnid;
|
||||||
arg->mi_self_latter_reader_txnid = arg->mi_latter_reader_txnid =
|
for (unsigned i = 0; i < arg->mi_numreaders; ++i) {
|
||||||
arg->mi_recent_txnid;
|
const uint32_t pid =
|
||||||
for (unsigned i = 0; i < arg->mi_numreaders; ++i) {
|
atomic_load32(&lck->mti_readers[i].mr_pid, mo_AcquireRelease);
|
||||||
const uint32_t pid =
|
if (pid) {
|
||||||
atomic_load32(&lck->mti_readers[i].mr_pid, mo_AcquireRelease);
|
const txnid_t txnid = safe64_read(&lck->mti_readers[i].mr_txnid);
|
||||||
if (pid) {
|
if (arg->mi_latter_reader_txnid > txnid)
|
||||||
const txnid_t txnid = safe64_read(&lck->mti_readers[i].mr_txnid);
|
arg->mi_latter_reader_txnid = txnid;
|
||||||
if (arg->mi_latter_reader_txnid > txnid)
|
if (pid == env->me_pid && arg->mi_self_latter_reader_txnid > txnid)
|
||||||
arg->mi_latter_reader_txnid = txnid;
|
arg->mi_self_latter_reader_txnid = txnid;
|
||||||
if (pid == env->me_pid && arg->mi_self_latter_reader_txnid > txnid)
|
|
||||||
arg->mi_self_latter_reader_txnid = txnid;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -19596,6 +19593,9 @@ __cold int mdbx_env_info_ex(const MDBX_env *env, const MDBX_txn *txn,
|
|||||||
rc = fetch_envinfo_ex(env, txn, arg, bytes);
|
rc = fetch_envinfo_ex(env, txn, arg, bytes);
|
||||||
if (unlikely(rc != MDBX_SUCCESS))
|
if (unlikely(rc != MDBX_SUCCESS))
|
||||||
return rc;
|
return rc;
|
||||||
|
snap.mi_since_sync_seconds16dot16 = arg->mi_since_sync_seconds16dot16;
|
||||||
|
snap.mi_since_reader_check_seconds16dot16 =
|
||||||
|
arg->mi_since_reader_check_seconds16dot16;
|
||||||
if (likely(memcmp(&snap, arg, bytes) == 0))
|
if (likely(memcmp(&snap, arg, bytes) == 0))
|
||||||
return MDBX_SUCCESS;
|
return MDBX_SUCCESS;
|
||||||
memcpy(&snap, arg, bytes);
|
memcpy(&snap, arg, bytes);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user