dant3 commented on code in PR #7250:
URL: https://github.com/apache/ignite-3/pull/7250#discussion_r2651397934
##########
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/persistence/checkpoint/CheckpointReadWriteLock.java:
##########
@@ -181,15 +192,37 @@ public boolean hasQueuedWriters() {
return checkpointLock.hasQueuedWriters();
}
- private void onReadLock(long start, boolean taken) {
- long elapsed = coarseCurrentTimeMillis() - start;
+ private void onReadLock(long startNanos, boolean taken) {
+ metrics.decrementReadLockWaitingThreads();
+
+ long currentNanos = System.nanoTime();
+ long elapsedNanos = TimeUnit.NANOSECONDS.toMillis(currentNanos -
startNanos);
if (taken) {
- checkpointReadLockHoldCount.set(checkpointReadLockHoldCount.get()
+ 1);
+ int newLockCount = checkpointReadLockHoldCount.get() + 1;
+ checkpointReadLockHoldCount.set(newLockCount);
+
+ // We only record acquisition time on first lock acquisition (not
on reentrant locks).
+ if (newLockCount == 1) {
+ checkpointReadLockAcquiredTime.set(currentNanos);
+ }
+ metrics.recordReadLockAcquisitionTime(elapsedNanos);
}
- if (elapsed > LONG_LOCK_THRESHOLD_MILLIS) {
- log.warn(LONG_LOCK_THROTTLE_KEY, "Checkpoint read lock took {} ms
to acquire.", elapsed);
+ if (elapsedNanos > LONG_LOCK_THRESHOLD_MILLIS) {
+ log.warn(LONG_LOCK_THROTTLE_KEY, "Checkpoint read lock took {} ms
to acquire.", elapsedNanos);
+ }
+ }
+
+ private void onReadUnlock() {
+ int newLockCount = checkpointReadLockHoldCount.get() - 1;
+ checkpointReadLockHoldCount.set(newLockCount);
+ if (newLockCount == 0) {
+ // Fully unlocked - record hold duration.
+ Long acquiredTimeNanos = checkpointReadLockAcquiredTime.get();
+ checkpointReadLockAcquiredTime.set(null);
Review Comment:
Yeah, it is probably useless.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]