diff options
author | Holden Rohrer <hr@hrhr.dev> | 2020-03-26 03:28:41 +0000 |
---|---|---|
committer | Holden Rohrer <hr@hrhr.dev> | 2020-03-26 03:28:41 +0000 |
commit | 183b38854c8efef2af9e4118060bc2dc4a84befc (patch) | |
tree | c9d72bfeb393ce8aad9090eb1754caeb6bc06dda | |
parent | 5912a13ccb48313da191741931409a11b217d306 (diff) |
fixed bug which has been making me tear my hair out
-rw-r--r-- | tools/schedule.js | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/tools/schedule.js b/tools/schedule.js index f9604bf..c110bb3 100644 --- a/tools/schedule.js +++ b/tools/schedule.js @@ -87,7 +87,10 @@ 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].wt*num/weightsum)){ - weightsum -= jobq[0].wt; + // The second req is SO weird. Think about it this way: for len objs + // to be pushed, the "odds" of the job getting a push must >= len (pushed + // len times). But it gets num tries, so the odds*num >= len. + // The odds are wt/wtsum for each try. dequeued.push(...jobq.shift().data); } |