alex-plekhanov commented on code in PR #12884:
URL: https://github.com/apache/ignite/pull/12884#discussion_r2925269032


##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/evict/Random2LruPageEvictionTracker.java:
##########
@@ -80,35 +80,49 @@ public Random2LruPageEvictionTracker(
     }
 
     /** {@inheritDoc} */
-    @Override public void touchPage(long pageId) throws IgniteCheckedException 
{
+    @Override public void touchPage(long pageId) {
         int pageIdx = PageIdUtils.pageIndex(pageId);
-
-        long latestTs = compactTimestamp(U.currentTimeMillis());
-
-        assert latestTs >= 0 && latestTs < Integer.MAX_VALUE;
+        int trackingIdx = trackingIdx(pageIdx);
+        long trackingPtr = trackingArrPtr + trackingIdx * 8L;
 
         boolean success;
+        long trackingData;
+        long newTrackingData;
+        long ts;
+        int firstTs;
+        int secondTs;

Review Comment:
   It looks like there is no reason to extract these declaration outside the 
loop



##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/evict/Random2LruPageEvictionTracker.java:
##########
@@ -80,35 +80,49 @@ public Random2LruPageEvictionTracker(
     }
 
     /** {@inheritDoc} */
-    @Override public void touchPage(long pageId) throws IgniteCheckedException 
{
+    @Override public void touchPage(long pageId) {
         int pageIdx = PageIdUtils.pageIndex(pageId);
-
-        long latestTs = compactTimestamp(U.currentTimeMillis());
-
-        assert latestTs >= 0 && latestTs < Integer.MAX_VALUE;
+        int trackingIdx = trackingIdx(pageIdx);
+        long trackingPtr = trackingArrPtr + trackingIdx * 8L;
 
         boolean success;
+        long trackingData;
+        long newTrackingData;
+        long ts;
+        int firstTs;
+        int secondTs;
 
         do {
-            int trackingIdx = trackingIdx(pageIdx);
+            trackingData = GridUnsafe.getLongVolatile(null, trackingPtr);
 
-            long trackingData = GridUnsafe.getLongVolatile(null, 
trackingArrPtr + trackingIdx * 8L);
+            firstTs = first(trackingData);
 
-            int firstTs = first(trackingData);
+            if (firstTs <= 0) // Concurrently evicted.
+                return;
 
-            assert firstTs >= 0 : "[firstTs=" + firstTs + ", trackingData=" + 
trackingData + "]";
+            ts = compactTimestamp(U.currentTimeMillis());
 
-            int secondTs = second(trackingData);
+            assert ts >= 0 && ts < Integer.MAX_VALUE;
 
-            long newTrackingData;
+            secondTs = second(trackingData);
 
             if (firstTs <= secondTs)
-                newTrackingData = U.toLong((int)latestTs, secondTs);
+                newTrackingData = U.toLong((int)ts, secondTs);
             else
-                newTrackingData = U.toLong(firstTs, (int)latestTs);
+                newTrackingData = U.toLong(firstTs, (int)ts);
+
+            success = GridUnsafe.compareAndSwapLong(null, trackingPtr, 
trackingData, newTrackingData);
+        }
+        while (!success);
+    }
+
+    /** */
+    @Override protected void initPage(long pageId) {
+        int ts = (int)compactTimestamp(U.currentTimeMillis());
+
+        long trackingPtr = trackingArrPtr + 
trackingIdx(PageIdUtils.pageIndex(pageId)) * 8L;
 
-            success = GridUnsafe.compareAndSwapLong(null, trackingArrPtr + 
trackingIdx * 8L, trackingData, newTrackingData);
-        } while (!success);
+        GridUnsafe.compareAndSwapLong(null, trackingPtr, 0, U.toLong(ts, ts));

Review Comment:
   `U.toLong(ts, 0)`?



-- 
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]

Reply via email to