diff options
author | Holden Rohrer <hr@hrhr.dev> | 2020-01-31 17:35:08 -0500 |
---|---|---|
committer | Holden Rohrer <hr@hrhr.dev> | 2020-01-31 17:48:43 -0500 |
commit | 31363c7baad1a065f552bad93e7be6a32200cf75 (patch) | |
tree | 6e166db52ba575d6a0d64b4b86e577a6095bdb88 /tools | |
parent | 0e2883105e948ff6f35f954f8184fdd232d17a97 (diff) |
proper mathematical fix in scheduler
Diffstat (limited to 'tools')
-rw-r--r-- | tools/schedule.js | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/tools/schedule.js b/tools/schedule.js index 3254a24..6173e94 100644 --- a/tools/schedule.js +++ b/tools/schedule.js @@ -87,14 +87,14 @@ exports.Queue = function(delayms, maxExport, call){ // Step 2: Start at lowest, and pop all until job.data.length>job.normweight*num (decreasing num as popping and recalc job.normweight). Delete the job. let weightsum = jobq.map(job => job.wt).reduce((acc, cur)=>acc+cur); while (jobq[0] && jobq[0].data.length<(jobq[0].wacc+jobq[0].wt*num/weightsum)){ - num -= jobq[0].data.length; weightsum -= jobq[0].wt; dequeued.push(...jobq.shift().data); } // Step 3: Then, pop job.normweight*num//1 elems from remaining, without num decrease or normweight recalc. But keep job.wacc = job.normweight*num%1 + let efflen = num - dequeued.length; for (job of jobq){ - job.wacc += job.wt*num/weightsum; + job.wacc += job.wt*efflen/weightsum; let data = job.data; let topop = job.wacc-job.wacc%1; job.wacc -= topop |