Skip to content

High CPU usage on Dish / Draft #708

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

Open
bergmorten opened this issue Mar 13, 2025 · 3 comments
Open

High CPU usage on Dish / Draft #708

bergmorten opened this issue Mar 13, 2025 · 3 comments
Labels

Comments

@bergmorten
Copy link

bergmorten commented Mar 13, 2025

**When waiting for messages with the UDP dish it consumes a lot of CPU

import { Dish } from 'zeromq/draft';
import { cpuUsage } from 'process';

const group = 'demo';
async function run() {
  const dish = new Dish();
  dish.join(group);
  await dish.bind('udp://127.0.0.1:3000');

  console.log('Subscriber connected to port 3000');

 // same issue with for await (const [msg, {group}] of dish) 
  while (true) {
    const [message] = await dish.receive();
    console.log('received message:', message.toString());
  }
}

const startUsage = cpuUsage();
const printUsage = () => {
  const usage = cpuUsage(startUsage);

  console.log(`CPU Usage: `, usage);
};

setInterval(printUsage, 1000);

run();

Tested on

  • OS: Windows, node 20
  • ZeroMQ.js version: 6.3.0
@bergmorten bergmorten added the bug label Mar 13, 2025
@bergmorten
Copy link
Author

Maybe related to #429

@aminya
Copy link
Member

aminya commented Mar 13, 2025

Can you try with the latest version instead of 6.0.0?

@bergmorten
Copy link
Author

Sorry that was a typo, I'm using latest 6.3.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants