You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by "ArbaazKhan1 (via GitHub)" <gi...@apache.org> on 2024/02/09 17:44:04 UTC

[PR] Replaced System.currentTimeMillis() with System.nanoTime() [accumulo]

ArbaazKhan1 opened a new pull request, #4250:
URL: https://github.com/apache/accumulo/pull/4250

   Fixed bug, by replacing `System.currentTimeMillis()` with `System.nanoTime()`. 
   Fixes  [issue 4245](https://github.com/apache/accumulo/issues/4245)


-- 
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-unsubscribe@accumulo.apache.org

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


Re: [PR] Replaced System.currentTimeMillis() with System.nanoTime() [accumulo]

Posted by "DomGarguilo (via GitHub)" <gi...@apache.org>.
DomGarguilo commented on code in PR #4250:
URL: https://github.com/apache/accumulo/pull/4250#discussion_r1486335429


##########
server/tserver/src/main/java/org/apache/accumulo/tserver/log/DfsLogger.java:
##########
@@ -186,7 +187,7 @@ public void run() {
         } catch (IOException | RuntimeException ex) {
           fail(work, ex, "synching");
         }
-        long duration = System.currentTimeMillis() - start;
+        long duration = NANOSECONDS.toMillis(System.nanoTime() - start);
         if (duration > slowFlushMillis) {

Review Comment:
   I think it would be best to convert `slowFlushMillis` to nanos and then keep `start` and `duration` as nanos too. That way you are getting the benefits of using nanos without having to loose precision by converting back to millis.
   
   That being said, if needed I think its fine to convert from nanos to millis for logging purposes



-- 
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-unsubscribe@accumulo.apache.org

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


Re: [PR] Replaced System.currentTimeMillis() with System.nanoTime() [accumulo]

Posted by "ddanielr (via GitHub)" <gi...@apache.org>.
ddanielr commented on code in PR #4250:
URL: https://github.com/apache/accumulo/pull/4250#discussion_r1484845633


##########
server/tserver/src/main/java/org/apache/accumulo/tserver/log/DfsLogger.java:
##########
@@ -186,7 +186,7 @@ public void run() {
         } catch (IOException | RuntimeException ex) {
           fail(work, ex, "synching");
         }
-        long duration = System.currentTimeMillis() - start;
+        long duration = System.nanoTime() - start;
         if (duration > slowFlushMillis) {

Review Comment:
   I don't think this comparison will work correctly comparing nanoseconds to milliseconds
   



-- 
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-unsubscribe@accumulo.apache.org

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


Re: [PR] Replaced System.currentTimeMillis() with System.nanoTime() [accumulo]

Posted by "DomGarguilo (via GitHub)" <gi...@apache.org>.
DomGarguilo commented on code in PR #4250:
URL: https://github.com/apache/accumulo/pull/4250#discussion_r1486335429


##########
server/tserver/src/main/java/org/apache/accumulo/tserver/log/DfsLogger.java:
##########
@@ -186,7 +187,7 @@ public void run() {
         } catch (IOException | RuntimeException ex) {
           fail(work, ex, "synching");
         }
-        long duration = System.currentTimeMillis() - start;
+        long duration = NANOSECONDS.toMillis(System.nanoTime() - start);
         if (duration > slowFlushMillis) {

Review Comment:
   I think it would be best to convert `slowFlushMillis` to nanos and then keep `start` and `duration` as nanos too. That way you are getting the benefits of using nanos without having to loose precision by converting back to millis.



-- 
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-unsubscribe@accumulo.apache.org

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


Re: [PR] Replaced System.currentTimeMillis() with System.nanoTime() [accumulo]

Posted by "EdColeman (via GitHub)" <gi...@apache.org>.
EdColeman commented on code in PR #4250:
URL: https://github.com/apache/accumulo/pull/4250#discussion_r1484663165


##########
server/tserver/src/main/java/org/apache/accumulo/tserver/log/DfsLogger.java:
##########
@@ -186,7 +186,7 @@ public void run() {
         } catch (IOException | RuntimeException ex) {
           fail(work, ex, "synching");
         }
-        long duration = System.currentTimeMillis() - start;
+        long duration = System.nanoTime() - start;
         if (duration > slowFlushMillis) {
           log.info("Slow sync cost: {} ms, current pipeline: {}", duration,

Review Comment:
   This should probably convert the display value to milliseconds `NANOSECONDS.toMillis(duration)` - using a static import of NANOSECONDS. 



-- 
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-unsubscribe@accumulo.apache.org

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


Re: [PR] Replaced System.currentTimeMillis() with System.nanoTime() [accumulo]

Posted by "DomGarguilo (via GitHub)" <gi...@apache.org>.
DomGarguilo merged PR #4250:
URL: https://github.com/apache/accumulo/pull/4250


-- 
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-unsubscribe@accumulo.apache.org

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