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

Linux - Node os.cpus polyfill - speed not defined #27555

Closed
sebhildebrandt opened this issue Jan 4, 2025 · 1 comment · Fixed by #27592
Closed

Linux - Node os.cpus polyfill - speed not defined #27555

sebhildebrandt opened this issue Jan 4, 2025 · 1 comment · Fixed by #27592
Labels
bug Something isn't working correctly node compat

Comments

@sebhildebrandt
Copy link

sebhildebrandt commented Jan 4, 2025

Version: Deno 2.1.4
OS: Linux (Ubuntu 20.04.6 LTS)
Function: Node polyfill os.cpus()

In Linux (tested on Ubuntu 20.04.6 LTS and 22.04.3 LTS), the os.cpus() polyfill seems to have an issue with [].speed(compared to node.js implementation)

Steps to reproduce:

c.ts:

import os from "node:os";
console.log(os.cpus());

Running this with deno (v 2.1.4) will give the following output:

deno -A c.ts
[
  [Object: null prototype] {
    model: "Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz",
    speed: 0,
    times: [Object: null prototype] {
      user: 55050465,
      nice: 16282,
      sys: 16903204,
      idle: 13698348421,
      irq: 6010237
    }
  },
  ...
]

cpus[i].speed is 0 / undefined

In Node.js we have

 os.cpus()
[
  {
    model: 'Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz',
    speed: 4715,
    times: {
      user: 550507000,
      nice: 162820,
      sys: 169032310,
      idle: 136983577930,
      irq: 0
    }
  },
  ...
]

cpus[i].speed is defined and not 0

@marvinhagemeister marvinhagemeister added bug Something isn't working correctly node compat labels Jan 4, 2025
littledivy added a commit to littledivy/deno that referenced this issue Jan 8, 2025
@sebhildebrandt
Copy link
Author

Awesome, thank you!!!!

dsherret pushed a commit that referenced this issue Jan 9, 2025
Populate `speed` using current scaling frequency and fix times
multiplier.

Fixes #27555

<table>
<tr>
<th>Node.js</th>
<th>Deno</th>
</tr>
<tr>
<td>

```
> os.cpus()
[
  {
    model: 'AMD Ryzen 5 7530U with Radeon Graphics',
    speed: 1396,
    times: {
      user: 1769930,
      nice: 20,
      sys: 525630,
      idle: 41325700,
      irq: 110060
    }
  },
```

</td>
<td>

```
> os.cpus()
[
  {
    model: "AMD Ryzen 5 7530U with Radeon Graphics",
    speed: 1630,
    times: [Object: null prototype] {
      user: 1795620,
      nice: 20,
      sys: 537840,
      idle: 41589390,
      irq: 111230
    }
  },
```

</td>
</tr>
</table>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly node compat
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants