You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by "Andrew Purtell (JIRA)" <ji...@apache.org> on 2019/02/07 18:39:00 UTC

[jira] [Commented] (HBASE-21774) do not use currentTimeMillis to measure intervals

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

Andrew Purtell commented on HBASE-21774:
----------------------------------------

Do we need something like Hadoop's Time#montonicNow? Maybe we can just use it directly in EnvironmentEdge#currentTime and then do (another!) global search and replace of System#currentTimeMillis with EnvironmentEdge#currentTime. The latter should be done regardless.

> do not use currentTimeMillis to measure intervals
> -------------------------------------------------
>
>                 Key: HBASE-21774
>                 URL: https://issues.apache.org/jira/browse/HBASE-21774
>             Project: HBase
>          Issue Type: Bug
>            Reporter: Sergey Shelukhin
>            Priority: Minor
>
> I've noticed it in a few places in the code... 
> currentMillis can go backwards and have other artifacts.
> nanoTime should be used for intervals (see [https://docs.oracle.com/javase/7/docs/api/java/lang/System.html#nanoTime()|https://docs.oracle.com/javase/7/docs/api/java/lang/System.html#nanoTime()] ) unless it's both the case that the calls are frequent and nanoTime will result in perf overhead, and also that artifacts from negative intervals and such are relatively harmless or possible to work around in the code.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)