@zukhruf/pool 0.6.6 → 0.6.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -6
- package/dist/eviction.d.ts +4 -0
- package/dist/eviction.d.ts.map +1 -0
- package/dist/eviction.js +2 -0
- package/dist/eviction.js.map +1 -0
- package/dist/idle-timeout.d.ts +9 -0
- package/dist/idle-timeout.d.ts.map +1 -0
- package/dist/idle-timeout.js +26 -0
- package/dist/idle-timeout.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/no-eviction.d.ts +5 -0
- package/dist/no-eviction.d.ts.map +1 -0
- package/dist/no-eviction.js +5 -0
- package/dist/no-eviction.js.map +1 -0
- package/dist/pool.d.ts +2 -0
- package/dist/pool.d.ts.map +1 -1
- package/dist/pool.js +91 -18
- package/dist/pool.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,23 +1,28 @@
|
|
|
1
1
|
# @zukhruf/pool
|
|
2
2
|
|
|
3
|
-
Lends long-lived workers to jobs, one job for each worker at a time. A worker is costly to start: a native helper that loads a model, or a command-line agent that keeps a session. The pool starts workers, lends them, replaces a worker that exits, and stops all of them when you dispose it. You choose
|
|
3
|
+
Lends long-lived workers to jobs, one job for each worker at a time. A worker is costly to start: a native helper that loads a model, or a command-line agent that keeps a session. The pool starts workers, lends them, replaces a worker that exits, and stops all of them when you dispose it. You choose three things from standard classes: when the workers start (a startup), how many run (a sizing), and when an idle worker closes (an eviction).
|
|
4
4
|
|
|
5
5
|
The words in these documents have one meaning each. See the glossary in [CONTEXT.md](./CONTEXT.md).
|
|
6
6
|
|
|
7
7
|
## Lend a worker to a job
|
|
8
8
|
|
|
9
9
|
```ts
|
|
10
|
-
import { Fixed, Parallel, Pool } from '@zukhruf/pool';
|
|
10
|
+
import { Fixed, IdleTimeout, Parallel, Pool } from '@zukhruf/pool';
|
|
11
11
|
|
|
12
12
|
await using pool = new Pool({
|
|
13
13
|
size: new Fixed(2),
|
|
14
14
|
startup: new Parallel(),
|
|
15
|
+
eviction: new IdleTimeout({ after: 300_000 }),
|
|
15
16
|
create: () => new VisionWorker('/path/to/vision-worker'),
|
|
16
17
|
});
|
|
17
18
|
const text = await pool.use((worker) => worker.read('/tmp/receipt.png'));
|
|
18
19
|
```
|
|
19
20
|
|
|
20
|
-
A worker gives `exited()`, `kill()`, `close()`, and optionally `ready()`. A `Coprocess` of `@zukhruf/coprocess` has all of them.
|
|
21
|
+
A worker gives `exited()`, `kill()`, `close()`, and optionally `ready()`. A `Coprocess` of `@zukhruf/coprocess` has all of them.
|
|
22
|
+
|
|
23
|
+
A job takes an idle worker first. When no worker is idle, the job takes a worker that starts. Only when no worker starts does the job start a new worker. Of the idle workers, a job takes the one in the lowest slot. Thus jobs one at a time use one worker, and the other idle workers stay idle until their eviction lets them go.
|
|
24
|
+
|
|
25
|
+
When a signal aborts a job that runs, the pool kills its worker. When a signal aborts a job whose worker still warms up, the warm-up continues for the next job.
|
|
21
26
|
|
|
22
27
|
The pool waits for `ready()` with no time limit. Thus, if the warm-up of a worker can wait forever, the worker sets its own time limit, and `ready()` rejects when that limit ends. The pool then kills and closes the worker, and the job that waits for it fails. The next job starts a new worker.
|
|
23
28
|
|
|
@@ -41,13 +46,26 @@ The pool waits for `ready()` with no time limit. Thus, if the warm-up of a worke
|
|
|
41
46
|
|
|
42
47
|
The two sizings that learn measure only while jobs wait and every worker is ready, in windows of at least 20 jobs and 2 seconds. They learn once, and never pass what the computer can give. See [ADR 0002](./docs/adr/0002-a-sizing-that-learns-compares-one-more-worker-between-two-windows.md).
|
|
43
48
|
|
|
49
|
+
## Choose when idle workers close
|
|
50
|
+
|
|
51
|
+
| Eviction | Evicts |
|
|
52
|
+
| ------------------------ | ------------------------------------------------------------ |
|
|
53
|
+
| `NoEviction` | no worker. Each idle worker stays until you dispose the pool |
|
|
54
|
+
| `IdleTimeout({ after })` | a worker that stays idle for `after` milliseconds |
|
|
55
|
+
|
|
56
|
+
A job that takes the worker before `after` ends keeps it. When the job ends, a new `after` starts. `after` is a number of milliseconds above 0 and at most 2,147,483,647. Another value throws a `RangeError`, because Node runs a timer with a larger delay after 1 ms.
|
|
57
|
+
|
|
58
|
+
Mature pools give these idle times: the .NET thread pool 20 s, generic-pool 30 s, KEDA and the Kubernetes HPA 300 s before they scale down, and HikariCP 10 minutes. A worker that is costly to start, such as a helper that loads a model, needs a long time. A worker that holds much memory needs a short time.
|
|
59
|
+
|
|
60
|
+
The pool evicts only a worker in a slot that the sizing runs. A worker that the sizing keeps but does not run stays alive for the next step of the sizing ([ADR 0002](./docs/adr/0002-a-sizing-that-learns-compares-one-more-worker-between-two-windows.md)). The next job that needs an evicted slot starts a new worker. See [ADR 0006](./docs/adr/0006-the-pool-evicts-an-idle-worker-that-its-eviction-lets-go-and-lends-an-idle-worker-first.md).
|
|
61
|
+
|
|
44
62
|
## Read the stats
|
|
45
63
|
|
|
46
64
|
A host can ask the pool how its workers are, for example in a health check:
|
|
47
65
|
|
|
48
66
|
```ts
|
|
49
67
|
const { starting, idle, lent, waiting } = pool.stats;
|
|
50
|
-
const healthy = idle + lent > 0;
|
|
68
|
+
const healthy = waiting === 0 || starting + idle + lent > 0;
|
|
51
69
|
```
|
|
52
70
|
|
|
53
71
|
| Count | Is |
|
|
@@ -57,11 +75,11 @@ const healthy = idle + lent > 0;
|
|
|
57
75
|
| `lent` | the ready workers that a job has |
|
|
58
76
|
| `waiting` | the jobs that wait for a worker: in the queue, or for a worker that starts |
|
|
59
77
|
|
|
60
|
-
A worker that exited is in no count. Each read makes a new object, so the counts of one read agree with each other. See [ADR 0004](./docs/adr/0004-a-pool-reports-its-stats-as-one-snapshot-of-counts.md).
|
|
78
|
+
A worker that exited is in no count, and a slot whose worker the pool evicted is in no count. Thus a pool with an eviction can show zero in each count and be healthy: the next job starts a worker. Each read makes a new object, so the counts of one read agree with each other. See [ADR 0004](./docs/adr/0004-a-pool-reports-its-stats-as-one-snapshot-of-counts.md).
|
|
61
79
|
|
|
62
80
|
## Replace a worker that exits
|
|
63
81
|
|
|
64
|
-
A job that needs the slot of an exited worker starts a new worker. An eager startup also replaces an idle worker that exits. After an early exit (a worker that ran less than 10 minutes), the pool waits first: 1 s, then 2 s, 4 s, and so on up to 60 s for each early exit in a row. A worker that runs 10 minutes ends this back-off. A job does not wait for a back-off: its worker starts now. Kubernetes restarts a container in CrashLoopBackOff with the same rule. See [ADR 0005](./docs/adr/0005-an-eager-pool-backs-off-before-it-replaces-a-worker-that-exited-early.md).
|
|
82
|
+
A job that needs the slot of an exited worker starts a new worker. An eager startup also replaces an idle worker that exits. After an early exit (a worker that ran less than 10 minutes), the pool waits first: 1 s, then 2 s, 4 s, and so on up to 60 s for each early exit in a row. A worker that runs 10 minutes ends this back-off. A job does not wait for a back-off: its worker starts now. Kubernetes restarts a container in CrashLoopBackOff with the same rule. The pool does not count an evicted worker as an exit: it does not replace the worker and does not start a back-off. An evicted worker that ran 10 minutes ends the back-off too. See [ADR 0005](./docs/adr/0005-an-eager-pool-backs-off-before-it-replaces-a-worker-that-exited-early.md).
|
|
65
83
|
|
|
66
84
|
## Decisions
|
|
67
85
|
|
|
@@ -70,3 +88,4 @@ A job that needs the slot of an exited worker starts a new worker. An eager star
|
|
|
70
88
|
- [ADR 0003](./docs/adr/0003-the-pool-learns-that-a-worker-ended-from-its-exit.md): the pool learns that a worker ended from its exit.
|
|
71
89
|
- [ADR 0004](./docs/adr/0004-a-pool-reports-its-stats-as-one-snapshot-of-counts.md): a pool reports its stats as one snapshot of counts.
|
|
72
90
|
- [ADR 0005](./docs/adr/0005-an-eager-pool-backs-off-before-it-replaces-a-worker-that-exited-early.md): an eager pool backs off before it replaces a worker that exited early.
|
|
91
|
+
- [ADR 0006](./docs/adr/0006-the-pool-evicts-an-idle-worker-that-its-eviction-lets-go-and-lends-an-idle-worker-first.md): the pool evicts an idle worker that its eviction lets go, and lends an idle worker first.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eviction.d.ts","sourceRoot":"","sources":["../src/eviction.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,QAAQ;IACvB,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;CAClD"}
|
package/dist/eviction.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eviction.js","sourceRoot":"","sources":["../src/eviction.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Eviction } from './eviction.ts';
|
|
2
|
+
export declare class IdleTimeout implements Eviction {
|
|
3
|
+
#private;
|
|
4
|
+
constructor(options: {
|
|
5
|
+
after: number;
|
|
6
|
+
});
|
|
7
|
+
idle(busy: AbortSignal, evict: () => void): void;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=idle-timeout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"idle-timeout.d.ts","sourceRoot":"","sources":["../src/idle-timeout.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAS9C,qBAAa,WAAY,YAAW,QAAQ;;gBAG9B,OAAO,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE;IAYtC,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,IAAI,GAAG,IAAI;CAOjD"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { addAbortListener } from 'node:events';
|
|
2
|
+
// The longest delay a Node timer keeps: a longer one runs after 1 ms.
|
|
3
|
+
const longest = 2_147_483_647;
|
|
4
|
+
// Evicts a worker that stays idle for after milliseconds, as the .NET thread
|
|
5
|
+
// pool retires a thread after 20 s and HikariCP closes a connection after its
|
|
6
|
+
// idleTimeout. A job that takes the worker first starts a new wait when it
|
|
7
|
+
// ends.
|
|
8
|
+
export class IdleTimeout {
|
|
9
|
+
#after;
|
|
10
|
+
constructor(options) {
|
|
11
|
+
if (!Number.isFinite(options.after) ||
|
|
12
|
+
options.after <= 0 ||
|
|
13
|
+
options.after > longest)
|
|
14
|
+
throw new RangeError(`An idle timeout is above 0 and at most ${longest} ms, not ${options.after}`);
|
|
15
|
+
this.#after = options.after;
|
|
16
|
+
}
|
|
17
|
+
idle(busy, evict) {
|
|
18
|
+
// A signal that aborted before the call starts no timer, as when the owner
|
|
19
|
+
// disposed the pool while the worker became ready.
|
|
20
|
+
if (busy.aborted)
|
|
21
|
+
return;
|
|
22
|
+
const timer = setTimeout(evict, this.#after);
|
|
23
|
+
addAbortListener(busy, () => clearTimeout(timer));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=idle-timeout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"idle-timeout.js","sourceRoot":"","sources":["../src/idle-timeout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAI/C,sEAAsE;AACtE,MAAM,OAAO,GAAG,aAAa,CAAC;AAE9B,6EAA6E;AAC7E,8EAA8E;AAC9E,2EAA2E;AAC3E,QAAQ;AACR,MAAM,OAAO,WAAW;IACb,MAAM,CAAS;IAExB,YAAY,OAA0B;QACpC,IACE,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC;YAC/B,OAAO,CAAC,KAAK,IAAI,CAAC;YAClB,OAAO,CAAC,KAAK,GAAG,OAAO;YAEvB,MAAM,IAAI,UAAU,CAClB,0CAA0C,OAAO,YAAY,OAAO,CAAC,KAAK,EAAE,CAC7E,CAAC;QACJ,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;IAC9B,CAAC;IAED,IAAI,CAAC,IAAiB,EAAE,KAAiB;QACvC,2EAA2E;QAC3E,mDAAmD;QACnD,IAAI,IAAI,CAAC,OAAO;YAAE,OAAO;QACzB,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAC7C,gBAAgB,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;IACpD,CAAC;CACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
export type { Eviction } from './eviction.ts';
|
|
1
2
|
export { Fixed } from './fixed.ts';
|
|
2
3
|
export { Gradient } from './gradient.ts';
|
|
3
4
|
export { HillClimbing } from './hill-climbing.ts';
|
|
5
|
+
export { IdleTimeout } from './idle-timeout.ts';
|
|
4
6
|
export { LeaderFirst } from './leader-first.ts';
|
|
7
|
+
export { NoEviction } from './no-eviction.ts';
|
|
5
8
|
export { OnDemand } from './on-demand.ts';
|
|
6
9
|
export { OrderedReady } from './ordered-ready.ts';
|
|
7
10
|
export { Parallel } from './parallel.ts';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,YAAY,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAClD,YAAY,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,YAAY,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,YAAY,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAClD,YAAY,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,YAAY,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export { Fixed } from "./fixed.js";
|
|
2
2
|
export { Gradient } from "./gradient.js";
|
|
3
3
|
export { HillClimbing } from "./hill-climbing.js";
|
|
4
|
+
export { IdleTimeout } from "./idle-timeout.js";
|
|
4
5
|
export { LeaderFirst } from "./leader-first.js";
|
|
6
|
+
export { NoEviction } from "./no-eviction.js";
|
|
5
7
|
export { OnDemand } from "./on-demand.js";
|
|
6
8
|
export { OrderedReady } from "./ordered-ready.js";
|
|
7
9
|
export { Parallel } from "./parallel.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-eviction.d.ts","sourceRoot":"","sources":["../src/no-eviction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAG9C,qBAAa,UAAW,YAAW,QAAQ;IACzC,IAAI,IAAI,IAAI;CACb"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-eviction.js","sourceRoot":"","sources":["../src/no-eviction.ts"],"names":[],"mappings":"AAEA,8EAA8E;AAC9E,MAAM,OAAO,UAAU;IACrB,IAAI,KAAU,CAAC;CAChB"}
|
package/dist/pool.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Eviction } from './eviction.ts';
|
|
1
2
|
import type { PoolStats } from './pool-stats.ts';
|
|
2
3
|
import type { Sizing } from './sizing.ts';
|
|
3
4
|
import type { Startup } from './startup.ts';
|
|
@@ -7,6 +8,7 @@ export declare class Pool<T extends Worker> implements AsyncDisposable {
|
|
|
7
8
|
constructor(options: {
|
|
8
9
|
size: Sizing;
|
|
9
10
|
startup: Startup;
|
|
11
|
+
eviction: Eviction;
|
|
10
12
|
create: () => T;
|
|
11
13
|
});
|
|
12
14
|
ready(): Promise<void>;
|
package/dist/pool.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pool.d.ts","sourceRoot":"","sources":["../src/pool.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"pool.d.ts","sourceRoot":"","sources":["../src/pool.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AA2C1C,qBAAa,IAAI,CAAC,CAAC,SAAS,MAAM,CAAE,YAAW,eAAe;;gBAchD,OAAO,EAAE;QACnB,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,OAAO,CAAC;QACjB,QAAQ,EAAE,QAAQ,CAAC;QACnB,MAAM,EAAE,MAAM,CAAC,CAAC;KACjB;IAsBK,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAK5B,IAAI,KAAK,IAAI,SAAS,CAarB;IAID,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC;IAyQlE,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC;CAQ7C"}
|
package/dist/pool.js
CHANGED
|
@@ -6,7 +6,8 @@ import { Latch, untilAborted } from '@zukhruf/async';
|
|
|
6
6
|
// 10 minutes ends the back-off.
|
|
7
7
|
const backoff = { first: 1_000, most: 60_000, reset: 600_000 };
|
|
8
8
|
// Lends workers to jobs, one job per worker at a time. The sizing decides how
|
|
9
|
-
// many workers run
|
|
9
|
+
// many workers run, the startup when they start, and the eviction when an
|
|
10
|
+
// idle worker closes. A job takes an idle worker first. A worker that exits is
|
|
10
11
|
// replaced when a job next needs its slot, or sooner when the startup is
|
|
11
12
|
// eager and the worker was idle: at once when it ran 10 minutes, after a
|
|
12
13
|
// back-off when it exited early. The owner disposes the pool, which stops
|
|
@@ -15,6 +16,7 @@ export class Pool {
|
|
|
15
16
|
#create;
|
|
16
17
|
#startup;
|
|
17
18
|
#sizing;
|
|
19
|
+
#eviction;
|
|
18
20
|
#queue;
|
|
19
21
|
#slots;
|
|
20
22
|
#lent = new Set();
|
|
@@ -27,6 +29,7 @@ export class Pool {
|
|
|
27
29
|
this.#create = options.create;
|
|
28
30
|
this.#startup = options.startup;
|
|
29
31
|
this.#sizing = options.size;
|
|
32
|
+
this.#eviction = options.eviction;
|
|
30
33
|
this.#queue = new PQueue({ concurrency: this.#sizing.current });
|
|
31
34
|
this.#slots = Array.from({ length: this.#sizing.ceiling }, (_, index) => ({
|
|
32
35
|
index,
|
|
@@ -75,8 +78,11 @@ export class Pool {
|
|
|
75
78
|
// while the job still holds its worker.
|
|
76
79
|
return this.#queue.add(async () => {
|
|
77
80
|
stop.throwIfAborted();
|
|
78
|
-
const slot = this.#
|
|
81
|
+
const slot = this.#pick();
|
|
79
82
|
this.#lent.add(slot);
|
|
83
|
+
// A job takes the worker before its eviction lets it go.
|
|
84
|
+
if (slot.state.kind === 'ready')
|
|
85
|
+
slot.state.idle.abort();
|
|
80
86
|
try {
|
|
81
87
|
const worker = await untilAborted(this.#borrow(slot), stop);
|
|
82
88
|
const kill = () => {
|
|
@@ -102,20 +108,38 @@ export class Pool {
|
|
|
102
108
|
}
|
|
103
109
|
finally {
|
|
104
110
|
this.#lent.delete(slot);
|
|
111
|
+
const state = slot.state;
|
|
105
112
|
if (slot.index >= this.#sizing.kept)
|
|
106
113
|
this.#retire(slot);
|
|
114
|
+
else if (state.kind === 'ready')
|
|
115
|
+
this.#rest(slot, state.worker, state.since);
|
|
116
|
+
else if (state.kind === 'lost')
|
|
117
|
+
this.#replace(slot, state.worker, state.since);
|
|
107
118
|
}
|
|
108
119
|
});
|
|
109
120
|
}
|
|
110
121
|
#running() {
|
|
111
122
|
return this.#slots.slice(0, this.#sizing.current);
|
|
112
123
|
}
|
|
124
|
+
// The slot a job takes, the lowest of its kind: an idle worker, else a
|
|
125
|
+
// worker that starts, else an empty slot or one whose worker ended, else a
|
|
126
|
+
// back-off. Jobs stay on the low slots, so the high ones stay idle until
|
|
127
|
+
// their eviction lets them go. This is the reason Commons Pool lends the
|
|
128
|
+
// object returned last (POOL-86) and Go's database/sql reuses the connection
|
|
129
|
+
// idle for the shortest time (sql.go:1336-1341).
|
|
130
|
+
#pick() {
|
|
131
|
+
const free = this.#running().filter((slot) => !this.#lent.has(slot));
|
|
132
|
+
return (free.find(({ state }) => state.kind === 'ready') ??
|
|
133
|
+
free.find(({ state }) => state.kind === 'starting') ??
|
|
134
|
+
free.find(({ state }) => state.kind === 'empty' || state.kind === 'lost') ??
|
|
135
|
+
free.find(({ state }) => state.kind === 'backoff'));
|
|
136
|
+
}
|
|
113
137
|
async #borrow(slot) {
|
|
114
138
|
const state = slot.state;
|
|
115
139
|
if (state.kind === 'ready')
|
|
116
140
|
return state.worker;
|
|
117
141
|
if (state.kind === 'lost') {
|
|
118
|
-
slot
|
|
142
|
+
this.#enter(slot, { kind: 'empty' });
|
|
119
143
|
void this.#close(state.worker);
|
|
120
144
|
}
|
|
121
145
|
// A job does not wait out a back-off: its worker starts now.
|
|
@@ -144,6 +168,14 @@ export class Pool {
|
|
|
144
168
|
return;
|
|
145
169
|
this.#queue.concurrency = this.#sizing.current;
|
|
146
170
|
this.#resized = performance.now();
|
|
171
|
+
// An idle worker waits for its eviction only while the pool runs its slot.
|
|
172
|
+
for (const slot of this.#slots.slice(0, this.#sizing.kept)) {
|
|
173
|
+
const state = slot.state;
|
|
174
|
+
if (state.kind === 'ready' &&
|
|
175
|
+
!this.#lent.has(slot) &&
|
|
176
|
+
state.idle.signal.aborted === slot.index < this.#sizing.current)
|
|
177
|
+
this.#rest(slot, state.worker, state.since);
|
|
178
|
+
}
|
|
147
179
|
for (const slot of this.#running())
|
|
148
180
|
if (slot.state.kind === 'empty')
|
|
149
181
|
this.#spawn(slot);
|
|
@@ -160,7 +192,7 @@ export class Pool {
|
|
|
160
192
|
}
|
|
161
193
|
#spawn(slot) {
|
|
162
194
|
const outcome = new Latch();
|
|
163
|
-
slot
|
|
195
|
+
this.#enter(slot, { kind: 'starting', outcome });
|
|
164
196
|
const turn = Promise.withResolvers();
|
|
165
197
|
this.#startup
|
|
166
198
|
.turn(turn.promise)
|
|
@@ -180,38 +212,79 @@ export class Pool {
|
|
|
180
212
|
})
|
|
181
213
|
.then((worker) => {
|
|
182
214
|
if (slot.state.kind === 'starting' && slot.state.outcome === outcome)
|
|
183
|
-
slot
|
|
215
|
+
this.#rest(slot, worker, performance.now());
|
|
184
216
|
outcome.open({ status: 'fulfilled', value: worker });
|
|
185
217
|
turn.resolve();
|
|
186
218
|
void worker.exited().then(() => this.#ended(slot, worker));
|
|
187
219
|
}, (reason) => {
|
|
188
220
|
if (slot.state.kind === 'starting' && slot.state.outcome === outcome)
|
|
189
|
-
slot
|
|
221
|
+
this.#enter(slot, { kind: 'empty' });
|
|
190
222
|
outcome.open({ status: 'rejected', reason });
|
|
191
223
|
turn.resolve();
|
|
192
224
|
});
|
|
193
225
|
return outcome;
|
|
194
226
|
}
|
|
227
|
+
// Every change of a slot's state comes here, so a ready worker that leaves
|
|
228
|
+
// its slot ends its idle wait.
|
|
229
|
+
#enter(slot, next) {
|
|
230
|
+
if (slot.state.kind === 'ready')
|
|
231
|
+
slot.state.idle.abort();
|
|
232
|
+
slot.state = next;
|
|
233
|
+
}
|
|
234
|
+
// A worker becomes idle in a slot. Its eviction may let it go only while
|
|
235
|
+
// no job has it and the pool runs its slot: a slot the sizing keeps but does
|
|
236
|
+
// not run has the worker the sizing tries (ADR 0002).
|
|
237
|
+
#rest(slot, worker, since) {
|
|
238
|
+
const state = {
|
|
239
|
+
kind: 'ready',
|
|
240
|
+
worker,
|
|
241
|
+
since,
|
|
242
|
+
idle: new AbortController(),
|
|
243
|
+
};
|
|
244
|
+
this.#enter(slot, state);
|
|
245
|
+
if (this.#lent.has(slot) || slot.index >= this.#sizing.current) {
|
|
246
|
+
state.idle.abort();
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
this.#eviction.idle(AbortSignal.any([state.idle.signal, this.#stopped.signal]), () => this.#evict(slot, state));
|
|
250
|
+
}
|
|
251
|
+
// Closes an idle worker that its eviction let go. The slot is empty before
|
|
252
|
+
// the worker closes, so its exit starts no back-off and no replacement. A
|
|
253
|
+
// worker that ran 10 minutes ends the back-off, as at an exit.
|
|
254
|
+
#evict(slot, state) {
|
|
255
|
+
if (slot.state !== state ||
|
|
256
|
+
this.#lent.has(slot) ||
|
|
257
|
+
slot.index >= this.#sizing.current ||
|
|
258
|
+
this.#stopped.signal.aborted)
|
|
259
|
+
return;
|
|
260
|
+
if (performance.now() - state.since >= backoff.reset)
|
|
261
|
+
slot.early = 0;
|
|
262
|
+
this.#retire(slot);
|
|
263
|
+
}
|
|
195
264
|
// The pool killed the worker of a slot: no job may borrow it any more.
|
|
196
265
|
#lose(slot, worker) {
|
|
197
266
|
const state = slot.state;
|
|
198
267
|
if (state.kind === 'ready' && state.worker === worker)
|
|
199
|
-
slot
|
|
268
|
+
this.#enter(slot, { kind: 'lost', worker, since: state.since });
|
|
200
269
|
}
|
|
201
270
|
#ended(slot, worker) {
|
|
202
271
|
const state = slot.state;
|
|
203
272
|
if ((state.kind !== 'ready' && state.kind !== 'lost') ||
|
|
204
273
|
state.worker !== worker)
|
|
205
274
|
return;
|
|
206
|
-
slot
|
|
207
|
-
if (this.#lent.has(slot)
|
|
208
|
-
this.#
|
|
209
|
-
|
|
275
|
+
this.#enter(slot, { kind: 'lost', worker, since: state.since });
|
|
276
|
+
if (!this.#lent.has(slot))
|
|
277
|
+
this.#replace(slot, worker, state.since);
|
|
278
|
+
}
|
|
279
|
+
// An eager pool closes the worker of a lost slot that no job has, and
|
|
280
|
+
// starts the next one: at once after a worker that ran 10 minutes, else
|
|
281
|
+
// after the back-off.
|
|
282
|
+
#replace(slot, worker, since) {
|
|
283
|
+
if (this.#stopped.signal.aborted || !this.#startup.eager)
|
|
210
284
|
return;
|
|
211
|
-
slot
|
|
285
|
+
this.#enter(slot, { kind: 'empty' });
|
|
212
286
|
void this.#close(worker);
|
|
213
|
-
slot.early =
|
|
214
|
-
performance.now() - state.since < backoff.reset ? slot.early + 1 : 0;
|
|
287
|
+
slot.early = performance.now() - since < backoff.reset ? slot.early + 1 : 0;
|
|
215
288
|
if (slot.index >= this.#sizing.current)
|
|
216
289
|
return;
|
|
217
290
|
if (slot.early === 0) {
|
|
@@ -219,21 +292,21 @@ export class Pool {
|
|
|
219
292
|
return;
|
|
220
293
|
}
|
|
221
294
|
const delay = Math.min(backoff.first * 2 ** (slot.early - 1), backoff.most);
|
|
222
|
-
slot
|
|
295
|
+
this.#enter(slot, {
|
|
223
296
|
kind: 'backoff',
|
|
224
297
|
timer: setTimeout(() => {
|
|
225
|
-
slot
|
|
298
|
+
this.#enter(slot, { kind: 'empty' });
|
|
226
299
|
if (slot.index < this.#sizing.current)
|
|
227
300
|
this.#spawn(slot);
|
|
228
301
|
}, delay),
|
|
229
|
-
};
|
|
302
|
+
});
|
|
230
303
|
}
|
|
231
304
|
// Closes the worker of a slot the pool no longer keeps, once its job ends.
|
|
232
305
|
#retire(slot) {
|
|
233
306
|
if (this.#lent.has(slot))
|
|
234
307
|
return;
|
|
235
308
|
const state = slot.state;
|
|
236
|
-
slot
|
|
309
|
+
this.#enter(slot, { kind: 'empty' });
|
|
237
310
|
if (state.kind === 'ready' || state.kind === 'lost')
|
|
238
311
|
void this.#close(state.worker);
|
|
239
312
|
else if (state.kind === 'backoff')
|
package/dist/pool.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pool.js","sourceRoot":"","sources":["../src/pool.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,SAAS,CAAC;AAE7B,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAOrD,4EAA4E;AAC5E,2EAA2E;AAC3E,2EAA2E;AAC3E,gCAAgC;AAChC,MAAM,OAAO,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;AAsB/D,8EAA8E;AAC9E,2EAA2E;AAC3E,yEAAyE;AACzE,yEAAyE;AACzE,0EAA0E;AAC1E,gBAAgB;AAChB,MAAM,OAAO,IAAI;IACN,OAAO,CAAU;IACjB,QAAQ,CAAU;IAClB,OAAO,CAAS;IAChB,MAAM,CAAS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AAM,CAAC,MAAM,KAAK,UAAU;QAAE,MAAM,MAAM,CAAC,MAAM,CAAC;IACtD,OAAO,MAAM,CAAC,KAAK,CAAC;AACtB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zukhruf/pool",
|
|
3
|
-
"version": "0.6.
|
|
4
|
-
"description": "Lend long-lived workers, such as native helper processes, to one job at a time: startups that decide when workers start, sizings that decide how many run, and replacement of a worker that exits.",
|
|
3
|
+
"version": "0.6.8",
|
|
4
|
+
"description": "Lend long-lived workers, such as native helper processes, to one job at a time: startups that decide when workers start, sizings that decide how many run, evictions that decide when an idle worker closes, and replacement of a worker that exits.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"access": "public"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@zukhruf/async": "^0.6.
|
|
44
|
+
"@zukhruf/async": "^0.6.8",
|
|
45
45
|
"p-queue": "10.0.0"
|
|
46
46
|
}
|
|
47
47
|
}
|