ascherbakoff commented on code in PR #4808:
URL: https://github.com/apache/ignite-3/pull/4808#discussion_r1863100923


##########
modules/core/src/test/java/org/apache/ignite/internal/hlc/HybridClockTest.java:
##########
@@ -75,13 +75,13 @@ public void testTick() {
         assertTimestampEquals(100, new HybridTimestamp(100, 2),
                 () -> clock.update(new HybridTimestamp(60, 1000)));
 
-        assertTimestampEquals(200, new HybridTimestamp(200, 0),
+        assertTimestampEquals(200, new HybridTimestamp(100, 3),

Review Comment:
   Why this changes are done?
   Clock behavior should remain the same.



##########
modules/core/src/main/java/org/apache/ignite/internal/hlc/HybridClockImpl.java:
##########
@@ -111,20 +111,30 @@ public final HybridTimestamp current() {
      */
     @Override
     public final HybridTimestamp update(HybridTimestamp requestTime) {
-        while (true) {
-            long now = currentTime();
+        long requestTimeLong = requestTime.longValue();
 
+        while (true) {
             // Read the latest time after accessing UTC time to reduce 
contention.
-            long oldLatestTime = latestTime;
+            long oldLatestTime = this.latestTime;
 
-            long newLatestTime = max(requestTime.longValue() + 1, max(now, 
oldLatestTime + 1));
+            if (oldLatestTime >= requestTimeLong) {
+                return hybridTimestamp(LATEST_TIME.incrementAndGet(this));

Review Comment:
   Let's introduce a microbenchmark specific to clock.
   Benchmark results should be attached to the PR.
   Make sure it didn't degrade.



##########
modules/core/src/main/java/org/apache/ignite/internal/hlc/HybridClockImpl.java:
##########
@@ -111,20 +111,30 @@ public final HybridTimestamp current() {
      */
     @Override
     public final HybridTimestamp update(HybridTimestamp requestTime) {
-        while (true) {
-            long now = currentTime();
+        long requestTimeLong = requestTime.longValue();

Review Comment:
   Making a copy here doesn't make sense to me.



##########
modules/core/src/main/java/org/apache/ignite/internal/hlc/HybridClockImpl.java:
##########
@@ -111,20 +111,30 @@ public final HybridTimestamp current() {
      */
     @Override
     public final HybridTimestamp update(HybridTimestamp requestTime) {
-        while (true) {
-            long now = currentTime();
+        long requestTimeLong = requestTime.longValue();
 
+        while (true) {
             // Read the latest time after accessing UTC time to reduce 
contention.
-            long oldLatestTime = latestTime;
+            long oldLatestTime = this.latestTime;
 
-            long newLatestTime = max(requestTime.longValue() + 1, max(now, 
oldLatestTime + 1));
+            if (oldLatestTime >= requestTimeLong) {
+                return hybridTimestamp(LATEST_TIME.incrementAndGet(this));
+            }
 
-            // TODO https://issues.apache.org/jira/browse/IGNITE-23707 avoid 
CAS on logical part update.
+            long now = currentTime();
+
+            if (now > requestTimeLong) {
+                if (LATEST_TIME.compareAndSet(this, oldLatestTime, now)) {
+                    return hybridTimestamp(now);

Review Comment:
   What do you mean by "not changed by jumping up".
   Clock here is moved up to current physical time.



-- 
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: notifications-unsubscr...@ignite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to