improve ufuzz duty cycle heuristic (#4045)

This commit is contained in:
Alex Lam S.L
2020-08-08 20:10:19 +01:00
committed by GitHub
parent 91f078fe35
commit e2237d8cd2
2 changed files with 13 additions and 13 deletions

View File

@@ -38,10 +38,10 @@ jobs:
while !(npm install); do echo "'npm install' failed - retrying..."; done while !(npm install); do echo "'npm install' failed - retrying..."; done
PERIOD=1800000 PERIOD=1800000
if [[ $CAUSE == "schedule" ]]; then if [[ $CAUSE == "schedule" ]]; then
PERIOD=$(( 3600 * `node test/ufuzz/actions $BASE_URL $TOKEN` )) PERIOD=`node test/ufuzz/actions $BASE_URL $TOKEN`
fi fi
if (( $PERIOD == 0 )); then if (( $PERIOD == 0 )); then
echo "too many jobs in queue - exiting..." echo "too many jobs in queue - skipping..."
else else
node test/ufuzz/job $PERIOD node test/ufuzz/job $PERIOD
fi fi

View File

@@ -22,28 +22,28 @@ function read(url, callback) {
}); });
} }
var in_progress = 0, queued = 0; var queued = 0, total = 0;
var earliest, latest;
process.on("beforeExit", function() { process.on("beforeExit", function() {
if (queued > 3) { if (queued > 3) {
process.stdout.write("0"); process.stdout.write("0");
} else if (total < 2) {
process.stdout.write("3600000");
} else { } else {
process.stdout.write(Math.min(1000 * 20 / in_progress, 1500).toFixed(0)); process.stdout.write(Math.min(20 * (latest - earliest) / (total - 1), 5400000).toFixed(0));
} }
}); });
read(base + "/actions/workflows/ufuzz.yml/runs", function(reply) { read(base + "/actions/workflows/ufuzz.yml/runs?event=schedule", function(reply) {
reply.workflow_runs.filter(function(workflow) { reply.workflow_runs.filter(function(workflow) {
return /^(in_progress|queued|)$/.test(workflow.status); return /^(in_progress|queued|)$/.test(workflow.status);
}).forEach(function(workflow) { }).forEach(function(workflow) {
read(workflow.jobs_url, function(reply) { read(workflow.jobs_url, function(reply) {
reply.jobs.forEach(function(job) { reply.jobs.forEach(function(job) {
switch (job.status) { if (job.status == "queued") queued++;
case "in_progress": total++;
in_progress++; var start = new Date(job.started_at);
break; if (!(earliest < start)) earliest = start;
case "queued": if (!(latest > start)) latest = start;
queued++;
break;
}
}); });
}); });
}); });