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

Limit CPU usage by a quota #462

Closed
2 tasks done
rraallvv opened this issue Dec 26, 2018 · 0 comments
Closed
2 tasks done

Limit CPU usage by a quota #462

rraallvv opened this issue Dec 26, 2018 · 0 comments

Comments

@rraallvv
Copy link

New issue checklist

Question or Feature Request

When deploying multiple miners to systems with different specs, I always find myself having to tweak throttleAfter and throttleWait for each miner separately. Since the CPU usage is highly dependent on those values, and they don't have the same effect on each separate worker. That's I was wondering whether it would be possible to use something like follows in the function _singleMiner in MinerWorkerPool.js to be able to limit the CPU usage to a quota instead of using throttleAfter and throttleWait

_singleMiner(nonceRange) {
    const start = Date.now();

    while(...) {
        ...
    }

    const end = Date.now();

    if (this._miningEnabled) {
        setTimeout(() => this._singleMiner(nonceRange), (end - start) * fraction);
    }
}

The variable fraction could be calculated from a desired CPU quota like this:

miningTime = end - start
idleTime = fraction * miningTime

doing some math:

CPUquota = miningTime / (miningTime + idleTime) * 100
         = miningTime / (miningTime + fraction * miningTime) * 100
         = 1 / (1 + fraction) * 100

Which give us:

fraction = (100 / CPUquota - 1)

Where CPUquota could be just some value passed to the miner, just like throttleAfter or throttleWait

@jeffesquivels jeffesquivels closed this as not planned Won't fix, can't repro, duplicate, stale Sep 28, 2022
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

2 participants