Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

timers: backport f8193ab. #8034

Closed

Conversation

misterdjules
Copy link

Original commit message:

timers: use uv_now instead of Date.now

This saves a few calls to gettimeofday which can be expensive, and
potentially subject to clock drift. Instead use the loop time which
uses hrtime internally.

In addition to the backport, this commit:

  • keeps _idleStart timers' property which is still set to
    Date.now() to avoid breaking existing code that uses it, even if
    its use is discouraged.
  • adds automated tests. These tests use a specific branch of
    libfaketime that hasn't been submitted upstream yet. libfaketime
    is git cloned if needed when running automated tests.

Original commit message:

 timers: use uv_now instead of Date.now

 This saves a few calls to gettimeofday which can be expensive, and
 potentially subject to clock drift. Instead use the loop time which
 uses hrtime internally.

In addition to the backport, this commit:
 - keeps _idleStart timers' property which is still set to
   Date.now() to avoid breaking existing code that uses it, even if
   its use is discouraged.
 - adds automated tests. These tests use a specific branch of
   libfaketime that hasn't been submitted upstream yet. libfaketime
   is git cloned if needed when running automated tests.
@tjfontaine
Copy link

Thanks, landed in befbbad

@tjfontaine tjfontaine closed this Jul 31, 2014
misterdjules pushed a commit to misterdjules/node that referenced this pull request Aug 26, 2014
PR nodejs#8034 came with a test to make sure that timers expiry is based on
monotonic time and not on wall-clock time. However, a bug in the
implementation broke timers with non-integer delays. A fix for this
issue was provided with PR nodejs#8073, but it didn't come with a test.

Because nodejs#8073 fixed a subtle issue that could reappear in the future,
and because the impact of such an issue would be significant, I suggest
adding this test.

The test would timeout after 1 minute if the issue was reproduced.
Otherwise it will run very quickly.
misterdjules pushed a commit to misterdjules/node that referenced this pull request Aug 27, 2014
PR nodejs#8034 came with a test to make sure that timers expiry is based on
monotonic time and not on wall-clock time. However, a bug in the
implementation broke timers with non-integer delays. A fix for this
issue was provided with PR nodejs#8073, but it didn't come with a test.

Because nodejs#8073 fixed a subtle issue that could reappear in the future,
and because the impact of such an issue would be significant, I suggest
adding this test.

The test would timeout after 1 minute if the issue was reproduced.
Otherwise it will run very quickly.
indutny pushed a commit that referenced this pull request Sep 2, 2014
PR #8034 came with a test to make sure that timers expiry is based on
monotonic time and not on wall-clock time. However, a bug in the
implementation broke timers with non-integer delays. A fix for this
issue was provided with PR #8073, but it didn't come with a test.

Because #8073 fixed a subtle issue that could reappear in the future,
and because the impact of such an issue would be significant, I suggest
adding this test.

The test would timeout after 1 minute if the issue was reproduced.
Otherwise it will run very quickly.

Reviewed-By: Fedor Indutny <fedor@indutny.com>
mscdex pushed a commit to mscdex/node that referenced this pull request Dec 25, 2014
PR nodejs#8034 came with a test to make sure that timers expiry is based on
monotonic time and not on wall-clock time. However, a bug in the
implementation broke timers with non-integer delays. A fix for this
issue was provided with PR nodejs#8073, but it didn't come with a test.

Because nodejs#8073 fixed a subtle issue that could reappear in the future,
and because the impact of such an issue would be significant, I suggest
adding this test.

The test would timeout after 1 minute if the issue was reproduced.
Otherwise it will run very quickly.

Reviewed-By: Fedor Indutny <fedor@indutny.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants