You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
process.uptime() not correct when adjust time #2573
Now , iojs use relative time to compute uptime[1], but when call settimeofday to change time, process.time() isn't correct. So, my PR #2572 is to slove this, using time that refer to the kernel boot time.
That's always ok at most platforms.
but when call settimeofday to change time, process.time isn't correct
process.time is a typo of process.uptime?
On what platform are you seeing this? I'm not sure I understand, libuv uses monotonic clocks - i.e. clocks that are unaffected by settimeofday - whenever possible.
I mean js-function process.time() implemented in static void Uptime(...).
There is no process.time() but I understand that you mean process.uptime(). I ask because there is also process.hrtime() which does something else.
uv_now() can be affected by settimeofday, so I use uv_uptime().
Can you explain how? Like I said, libuv uses monotonic clocks (think clock_gettime(CLOCK_MONOTONIC)) on most platforms. You should never see the uptime jump backwards, although it is possible for a monotonic clock to slow down in the presence of time adjustments.
On some platforms it doesn't matter if you use uv_now() or uv_uptime() because they both call clock_gettime(). With that in mind, can you explain more about the exact behavior you're seeing and on what platform?
All of the BSDs use the same uv_uptime() implementation in libuv. process.uptime() uses a monotonic clock via uv_hrtime() whereas require('os').uptime() uses uv_uptime(). So are you referring to os.uptime() instead of process.uptime()?
I forgot the detail when I submitted netBSD patch in 3 years ago. Probably I referred FreeBSD implementation of uv_uptime().
I guess it comes from an old implementation of uptime(1) in FreeBSD and it was changed and has been using clock_gettime since 2005 as in freebsd/freebsd-src@74d3dde. We can change it in libuv now.
Activity
bnoordhuis commentedon Aug 27, 2015
process.timeis a typo ofprocess.uptime?On what platform are you seeing this? I'm not sure I understand, libuv uses monotonic clocks - i.e. clocks that are unaffected by
settimeofday- whenever possible.yjhjstz commentedon Aug 27, 2015
I mean js-function
process.time()implemented instatic void Uptime(...).uv_now()can be affected bysettimeofday, so I useuv_uptime(). @bnoordhuisbnoordhuis commentedon Aug 27, 2015
There is no
process.time()but I understand that you meanprocess.uptime(). I ask because there is alsoprocess.hrtime()which does something else.Can you explain how? Like I said, libuv uses monotonic clocks (think
clock_gettime(CLOCK_MONOTONIC)) on most platforms. You should never see the uptime jump backwards, although it is possible for a monotonic clock to slow down in the presence of time adjustments.On some platforms it doesn't matter if you use
uv_now()oruv_uptime()because they both callclock_gettime(). With that in mind, can you explain more about the exact behavior you're seeing and on what platform?yjhjstz commentedon Aug 27, 2015
in netbsd,
I want to know, why
uv_uptimenot useclock_gettime, but to usesysctl?bnoordhuis commentedon Aug 27, 2015
I don't know the exact reason. Someone (@shigeki?) contributed that code a long time ago.
mscdex commentedon Aug 27, 2015
All of the BSDs use the same
uv_uptime()implementation in libuv.process.uptime()uses a monotonic clock viauv_hrtime()whereasrequire('os').uptime()usesuv_uptime(). So are you referring toos.uptime()instead ofprocess.uptime()?shigeki commentedon Aug 28, 2015
I forgot the detail when I submitted netBSD patch in 3 years ago. Probably I referred FreeBSD implementation of
uv_uptime().I guess it comes from an old implementation of
uptime(1)in FreeBSD and it was changed and has been usingclock_gettimesince 2005 as in freebsd/freebsd-src@74d3dde. We can change it in libuv now.yjhjstz commentedon Aug 28, 2015
I think , we can update libuv implementation. And I was wondering why
os.uptime()implementation is different fromprocess.uptime().saghul commentedon Aug 31, 2015
FWIW, this landed in libuv, thanks @yjhjstz!
evanlucas commentedon Oct 20, 2015
This was fixed by the upgrade to libuv 1.7.5. Thanks!