Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: wasm worker manager #966

Merged
merged 36 commits into from
Jan 29, 2025
Merged
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
cfa9b01
feat: worker pooling
Natoandro Jan 15, 2025
3d77943
feat: min worker count
Natoandro Jan 15, 2025
7e4462e
timeout
Natoandro Jan 15, 2025
9be7ee4
refactor: pooling.ts
Natoandro Jan 16, 2025
ad8e667
feat: wait queue without timeout
Natoandro Jan 16, 2025
7838471
test: simple wait queue
Natoandro Jan 16, 2025
6487117
test: timeout
Natoandro Jan 16, 2025
94e9926
fix ajv version
Natoandro Jan 16, 2025
d57b4ea
fix tests
Natoandro Jan 16, 2025
2c4e0e2
fix
Natoandro Jan 17, 2025
4389e57
Merge branch 'main' into met-806-worker-pooling
Natoandro Jan 17, 2025
4f120b4
update
Natoandro Jan 20, 2025
b548328
Merge branch 'main' into met-806-worker-pooling
Natoandro Jan 20, 2025
ebf7188
bump to 0.5.1-rc.0
Natoandro Jan 20, 2025
49c5d1f
move all pooling relatd codes in pooling.ts
Natoandro Jan 21, 2025
577ed2a
shared pool
Natoandro Jan 21, 2025
348c359
lazy pool
Natoandro Jan 21, 2025
16a91dc
configuration variables
Natoandro Jan 21, 2025
4457e63
update docs
Natoandro Jan 22, 2025
faede60
wip: was worker management
luckasRanarison Jan 22, 2025
10f46df
fix pre-commit
Natoandro Jan 22, 2025
a4e178e
index on met-805-wasm-worker-manager: faede60a7 wip: was worker manag…
luckasRanarison Jan 23, 2025
415ebfb
On met-805-wasm-worker-manager: wip worker
luckasRanarison Jan 23, 2025
459dde5
wip: worker hostcall
luckasRanarison Jan 23, 2025
6be874a
feat: wasm worker manager
luckasRanarison Jan 24, 2025
b523445
Merge branch 'met-806-worker-pooling' into met-805-wasm-worker-manager
luckasRanarison Jan 24, 2025
93166df
Merge commit '415ebfb1f' into met-805-wasm-worker-manager
luckasRanarison Jan 26, 2025
7c860a4
fix: python tests
luckasRanarison Jan 27, 2025
30bb884
fix: pooling test
luckasRanarison Jan 27, 2025
39358a4
Merge branch 'main' into met-805-wasm-worker-manager
luckasRanarison Jan 28, 2025
4b8e000
fix: wit destroy handling
luckasRanarison Jan 28, 2025
3498852
fix: cleanup
luckasRanarison Jan 28, 2025
6a61cce
fix: docs & more cleanups
luckasRanarison Jan 28, 2025
6ff2bcd
fix: python tests
luckasRanarison Jan 28, 2025
2bc7721
fix: pooling cancelation
luckasRanarison Jan 29, 2025
af729a7
fix: make timer cleanup explicit
luckasRanarison Jan 29, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: pooling cancelation
Possible race condition so it is not guaranteed that there will be a
shifted item.
luckasRanarison committed Jan 29, 2025
commit 2bc77217a1852878f5b9e350b1d0fe1a9ee485f3
17 changes: 7 additions & 10 deletions src/typegate/src/runtimes/patterns/worker_manager/pooling.ts
Original file line number Diff line number Diff line change
@@ -21,7 +21,6 @@ export type Consumer<T> = (x: T) => void;
export interface WaitQueue<W> {
push(consumer: Consumer<W>, onCancel: () => void): void;
shift(produce: () => W): boolean;
clear(): void;
}

export function createSimpleWaitQueue<W>(): WaitQueue<W> {
@@ -38,7 +37,6 @@ export function createSimpleWaitQueue<W>(): WaitQueue<W> {
}
return false;
},
clear() {},
};
}

@@ -78,12 +76,6 @@ export class WaitQueueWithTimeout<W> implements WaitQueue<W> {
return false;
}

clear() {
if (this.#timerId != null) {
clearTimeout(this.#timerId);
}
}

#timeoutHandler() {
this.#cancelNextEntry();
this.#updateTimer();
@@ -105,7 +97,13 @@ export class WaitQueueWithTimeout<W> implements WaitQueue<W> {
}

#cancelNextEntry() {
this.#queue.shift()!.cancellationHandler();
this.#queue.shift()?.cancellationHandler();
}

[Symbol.dispose]() {
if (this.#timerId != null) {
clearTimeout(this.#timerId);
}
}
}

@@ -222,6 +220,5 @@ export class WorkerPool<
);
this.#idleWorkers.forEach((worker) => worker.destroy());
this.#idleWorkers = [];
this.#waitQueue.clear();
}
}