You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-issues@hadoop.apache.org by "Steve Loughran (Jira)" <ji...@apache.org> on 2021/06/07 13:09:00 UTC

[jira] [Commented] (HADOOP-17463) Replace currentTimeMillis with monotonicNow in elapsed time

    [ https://issues.apache.org/jira/browse/HADOOP-17463?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17358581#comment-17358581 ] 

Steve Loughran commented on HADOOP-17463:
-----------------------------------------

CPU cores have changed since the previous discussion and on recent intel x86 parts the TSC clock will be consistent across all cores in the same socket, so risk of going backwords on rescheduling is 0 for a single-socket device.
But: this absolutely doesn't hold for multisocket servers, and I don't know about AMD or ARM parts.

I do think we need some form of monotonic clock for our wait loops, or at least those where an NTP update could trigger a false failure. VM suspend/resume, well, that's where currentTimeMillis() is better than CPU counters -the virtual CPU clock may not have increased, but relative to the outside world, time has passed.

> Replace currentTimeMillis with monotonicNow in elapsed time
> -----------------------------------------------------------
>
>                 Key: HADOOP-17463
>                 URL: https://issues.apache.org/jira/browse/HADOOP-17463
>             Project: Hadoop Common
>          Issue Type: Bug
>            Reporter: Ahmed Hussein
>            Assignee: Ahmed Hussein
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 1h 40m
>  Remaining Estimate: 0h
>
> I noticed that there is a widespread incorrect usage of {{System.currentTimeMillis()}}  throughout the hadoop code.
> For example:
> {code:java}
> // Some comments here
> long start = System.currentTimeMillis();
> while (System.currentTimeMillis() - start < timeout) {
>   // Do something
> }
> {code}
> Elapsed time should be measured using `monotonicNow()`.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org