A worker has finished `job`: log it when it was slow, or when its caller had stopped waiting.
(job: Job)
| 534 | |
| 535 | /** A worker has finished `job`: log it when it was slow, or when its caller had stopped waiting. */ |
| 536 | private noteFinished(job: Job): void { |
| 537 | const now = Date.now(); |
| 538 | const started = job.startedAt ?? now; |
| 539 | if (job.busyAt !== undefined) { |
| 540 | this.log( |
| 541 | `${job.toolName} finished after running ${logSecs(now - started)}; its caller had been answered "busy" ` + |
| 542 | `${logSecs(now - job.busyAt)} earlier.`, |
| 543 | ); |
| 544 | } else if (!job.settled && now - job.enqueuedAt >= this.slowCallLogMs) { |
| 545 | this.log( |
| 546 | `Slow call: ${job.toolName} took ${logSecs(now - job.enqueuedAt)} ` + |
| 547 | `(waited ${logSecs(started - job.enqueuedAt)} for a worker, ran ${logSecs(now - started)}).`, |
| 548 | ); |
| 549 | } |
| 550 | } |
| 551 | |
| 552 | /** |
| 553 | * {@link run}, but only when a warm worker is idle right now, so the call |