Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

process.hrtime() is much slower in 14.x #36417

Closed
spazmodius opened this issue Dec 6, 2020 · 3 comments
Closed

process.hrtime() is much slower in 14.x #36417

spazmodius opened this issue Dec 6, 2020 · 3 comments

Comments

@spazmodius
Copy link

process.hrtime() takes twice as long to execute in Node.js 14, compared to Node.js 12.

  • Version: 14.15.0 vs 12.18.4
  • Platform: Microsoft Windows NT 10.0.19041.0 x64
  • Subsystem: process

What steps will reproduce the bug?

Running benchmark/process/bench-hrtime.js in Node.js 12 and 14

> node -v
v12.18.4

> node bm\process\bench-hrtime.js
process\bench-hrtime.js type="raw" n=1000000: 19,672,995.469309144
process\bench-hrtime.js type="diff" n=1000000: 20,285,745.00412815
process\bench-hrtime.js type="bigint" n=1000000: 20,371,868.07993106
v14.15.0
        
> node bm\process\bench-hrtime.js
process\bench-hrtime.js type="raw" n=1000000: 9,509,147.32426858
process\bench-hrtime.js type="diff" n=1000000: 9,260,999.984256301
process\bench-hrtime.js type="bigint" n=1000000: 9,194,852.721446535
@devsnek
Copy link
Member

devsnek commented Dec 6, 2020

hrtime should be about 2x faster in v15

@bzoz
Copy link
Contributor

bzoz commented Dec 7, 2020

Looks like this is already fixed:

v12.20.0
process\bench-hrtime.js type="raw" n=1000000: 19,145,131.584489383
process\bench-hrtime.js type="diff" n=1000000: 19,097,235.484191306
process\bench-hrtime.js type="bigint" n=1000000: 18,287,018.411370136

v14.15.1
process\bench-hrtime.js type="raw" n=1000000: 10,456,215.121987434
process\bench-hrtime.js type="diff" n=1000000: 10,417,621.615314737
process\bench-hrtime.js type="bigint" n=1000000: 9,485,326.20036803

v15.3.0
process\bench-hrtime.js type="raw" n=1000000: 20,348,612.428118527
process\bench-hrtime.js type="diff" n=1000000: 19,892,421.78299755
process\bench-hrtime.js type="bigint" n=1000000: 23,809,977.33290158

@bzoz bzoz closed this as completed Dec 7, 2020
@spazmodius
Copy link
Author

You mean fixed in 15? Because what you posted above still shows degradation in 14.15.1

spazmodius added a commit to spazmodius/now that referenced this issue May 28, 2021
On Node 14.x, hrtime() suffers from a performance regression, making this module worse than Date.now().

See nodejs/node#36417
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants