Enhance worker thread performance and add SocketWorker class#11
Merged
Conversation
…and reshape support - Measured benchmark fastest time increase from 3.516s to 2.845s.
…EventEmitter interface
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces a new benchmarking suite for the worker pool and makes several improvements to worker communication, task queue efficiency, and embedding result handling. The key changes include adding micro-benchmarks for threads and processes, improving how embedding results are transferred and reshaped, and optimizing the pending task queue for better performance under load.
Benchmarking and Testing:
bench/micro-bench.jsto compare thread and process worker pool performance, along with mock worker scripts for both process and thread modes. [1] [2] [3]Worker Communication and Embedding Handling:
Float32Arraybuffers for zero-copy efficiency, including shape metadata for proper reconstruction.number[][]arrays before resolving tasks, ensuring a consistent public API regardless of worker implementation.Performance and Robustness Improvements:
WorkerPoolwith a customFIFOQueueclass to avoid performance issues with large queues and frequentArray.shift()calls. [1] [2] [3] [4]New Worker Implementation:
SocketWorkerclass insrc/socket-worker.jsto support connecting to a socket-based model server using an NDJSON protocol, exposing an EventEmitter interface for compatibility with the pool.