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

Performance issue with bun.sh #887

Open
KwaiTushan opened this issue Feb 3, 2024 · 1 comment
Open

Performance issue with bun.sh #887

KwaiTushan opened this issue Feb 3, 2024 · 1 comment

Comments

@KwaiTushan
Copy link

KwaiTushan commented Feb 3, 2024

Describe the bug
The CPU usage spikes to around 80-90%, which is quite unusual. Even only call a small function
Using almaLinux, on a VPS (kvm, amd64, solusVM)

Environment (please complete the following information):

  • systeminformation package version: 5.21.24
  • OS: AlmaLinux8.2 and debian10
  • Hardware: KVM VPS on solusVM, amd64 (Actually i tried with other machines and it happens randomly which is super weird)
  • Bun.sh version: 1.0.25
import os from 'os';
import { currentLoad, cpu, networkStats, fsSize, osInfo, mem } from "systeminformation";

export const dataCollector = async () => {
    let nodeData: any = {};
    nodeData.loadavg = os.loadavg();
    nodeData.uptime = os.uptime();
    nodeData.platform = os.platform();
    const [
        cpuData,
        currentLoadData,
        memData,
        osInfoData,
        networkStatsData,
        fsSizeData,
    ] = await Promise.all([
        cpu(),
        currentLoad(),
        mem(),
        osInfo(),
        networkStats(),
        fsSize(),
    ]);

    nodeData.cpu = {
        cores: cpuData.cores,
        speedMax: cpuData.speedMax,
        speedMin: cpuData.speedMin,
        usage: Math.round(currentLoadData.currentLoad),
    };
    nodeData.mem = {
        used: memData.active,
        total: memData.total,
        swap: {
            used: memData.swapused,
            total: memData.swaptotal,
        },
    };
    nodeData.oslogo = osInfoData.logofile;
    nodeData.network = {
        rx: networkStatsData[0].rx_bytes,
        tx: networkStatsData[0].tx_bytes,
        rx_current: Math.round(networkStatsData[0].rx_sec) || 0,
        tx_current: Math.round(networkStatsData[0].tx_sec) || 0,
    };

    let totalSize = 0;
    let usedSize = 0;
    for (const fs of fsSizeData) {
        if (
            fs.type !== 'udev' &&
            fs.type !== 'tmpfs' &&
            fs.type !== 'overlay' &&
            fs.type !== 'devtmpfs' &&
            fs.type !== 'efivarfs'
        ) {
            totalSize += fs.size;
            usedSize += fs.used;
        }
    }
    nodeData.fs = {
        total: totalSize,
        used: usedSize,
    };

    return JSON.stringify(nodeData);
}
let isDataCollectionInProgress = false;
        const transmitter = setInterval(() => {
            if (!isDataCollectionInProgress) { // Only start collection if not already in progress
                isDataCollectionInProgress = true;
                (async () => {
                    try {
                        const data = await dataCollector();
                        console.log(data)
                    } finally {
                        isDataCollectionInProgress = false; // Signal completion
                    }
                })();
            }
}, 1000);
@sebhildebrandt
Copy link
Owner

@KwaiTushan I will test it tomorrow …

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

No branches or pull requests

2 participants