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

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: nodejs/node-v0.x-archive
base: af69f88a9d57
Choose a base ref
...
head repository: nodejs/node-v0.x-archive
compare: 632c13562220
Choose a head ref
  • 1 commit
  • 1 file changed
  • 1 contributor

Commits on Apr 10, 2014

  1. src: use monotonic time for process.uptime()

    `process.uptime()` interface will return the amount of time the
    current process has been running. To achieve this it was caching the
    `uv_uptime` value at program start, and then on the call to
    `process.uptime()` returning the delta between the two values.
    
    `uv_uptime` is defined as the number of seconds the operating system
    has been up since last boot. On sunos this interface uses `kstat`s
    which can be a significantly expensive operation as it requires
    exclusive access, but because of the design of `process.uptime()` node
    *had* to always call this on start. As a result if you had many node
    processes all starting at the same time you would suffer lock
    contention as they all tried to read kstats.
    
    Instead of using `uv_uptime` to achieve this, the libuv loop already
    has a concept of current loop time in the form of `uv_now()` which is
    in fact monotonically increasing, and already stored directly on the
    loop. By using this value at start every platform performs at least
    one fewer syscall during initialization.
    
    Since the interface to `uv_uptime` is defined as seconds, in the call
    to `process.uptime()` we now `uv_update_time` get our delta, divide by
    1000 to get seconds, and then convert to an `Integer`. In 0.12 we can
    move back to `Number::New` instead and not lose precision.
    
    Caveat: For some platforms `uv_uptime` reports time monotonically
    increasing regardless of system hibernation, `uv_now` interface is
    also monotonically increasing but may not reflect time spent in
    hibernation.
    tjfontaine committed Apr 10, 2014
    Copy the full SHA
    632c135 View commit details
    Browse the repository at this point in the history