How miskovy/parallel-javascript works
PJS is a persistent Node worker runtime for explicitly registered CPU tasks. Its main workflow is an application registering local module exports, creating and starting a runtime, submitting work, and receiving results before shutdown. Internally, task coordination feeds bounded admission and worker dispatch; workers bootstrap registered modules and communicate through a validated message protocol. Separate capabilities handle partitioned ranges and streams, buffer ownership and result backpressure, plus diagnostics. README documents these public capabilities; some subsystem links rely on documented behavior because their implementation was not sampled.
Main entry points: partition/coordinator.ts Partition coordinator · dispatcher.ts Execution dispatcher · runtime.ts PjsRuntime · tasks/coordinator.ts Task coordinator
Components 21
Runtime API
- PjsRuntime
packages/runtime/src/runtime.ts - Task registry
packages/runtime/src/tasks/registry.ts
Task Execution
- Task coordinator
packages/runtime/src/tasks/coordinator.ts - Execution dispatcher
packages/runtime/src/dispatch/dispatcher.ts - FIFO scheduler
packages/runtime/src/scheduler/fifo.ts
Worker System
- Worker pool
packages/runtime/src/pool/pool.ts - Worker host
packages/runtime/src/workers/worker.ts - Worker bootstrap
packages/runtime/src/workers/bootstrap.ts - Worker protocol
packages/runtime/src/workers/protocol.ts
Partitioned Work
- Partition coordinator
packages/runtime/src/partition/coordinator.ts - Range planning
packages/runtime/src/partition/range.ts - Range operations
packages/runtime/src/partition/operation.ts - Range streaming
packages/runtime/src/partition/stream.ts
Memory and Results
- Buffer transfer
packages/runtime/src/tasks/transfer.ts - Shared input
packages/runtime/src/tasks/shared.ts - Result credits
packages/runtime/src/results/credit.ts
Diagnostics
- Runtime metrics
packages/runtime/src/telemetry/metrics.ts - Internal profiling
packages/runtime/src/telemetry/profile.ts - Statistics surface
packages/runtime/src/telemetry/runtime.ts
Other components
- Node application
- Registered task modules
Connections 28
- Node application → Task registry: registers tasks
README.md - Node application → PjsRuntime: creates and runs
README.md - Task registry → Registered task modules: references exports
packages/runtime/src/tasks/registry.ts - PjsRuntime → Task registry: snapshots registry
packages/runtime/src/runtime.ts - PjsRuntime → Task coordinator: constructs coordinator
packages/runtime/src/runtime.ts - PjsRuntime → Execution dispatcher: constructs dispatcher
packages/runtime/src/runtime.ts - PjsRuntime → Partition coordinator: starts range work
packages/runtime/src/runtime.ts - Task coordinator → Execution dispatcher: submits tasks
packages/runtime/src/tasks/coordinator.ts - Execution dispatcher → FIFO scheduler: schedules tasks
packages/runtime/src/dispatch/dispatcher.ts - Execution dispatcher → Worker pool: dispatches through
packages/runtime/src/dispatch/dispatcher.ts - Worker pool → Worker host: spawns workers
packages/runtime/src/pool/pool.ts - Worker host → Worker bootstrap: starts bootstrap
packages/runtime/src/workers/worker.ts - Worker host → Worker protocol: validates messages
packages/runtime/src/workers/worker.ts - Worker bootstrap → Registered task modules: loads task exports
README.md - Partition coordinator → Range operations: creates operations
packages/runtime/src/partition/coordinator.ts - Partition coordinator → Range planning: plans partitions
packages/runtime/src/partition/coordinator.ts - Partition coordinator → Range streaming: produces stream results
packages/runtime/src/partition/coordinator.ts - Partition coordinator → Task coordinator: submits child tasks
packages/runtime/src/partition/coordinator.ts - Task coordinator → Buffer transfer: validates transfers
packages/runtime/src/tasks/coordinator.ts - Node application → Shared input: uses shared input
README.md - Partition coordinator → Result credits: accounts result capacity
packages/runtime/src/partition/coordinator.ts - Execution dispatcher → Result credits: marks dispatch and completion
packages/runtime/src/dispatch/dispatcher.ts - Task coordinator → Runtime metrics: records task metrics
packages/runtime/src/tasks/coordinator.ts - Execution dispatcher → Internal profiling: checks profiling
packages/runtime/src/dispatch/dispatcher.ts - PjsRuntime → Statistics surface: exposes statistics
packages/runtime/src/runtime.ts - Statistics surface → Execution dispatcher: reads execution stats
packages/runtime/src/telemetry/runtime.ts - Statistics surface → Partition coordinator: reads range stats
packages/runtime/src/telemetry/runtime.ts - Statistics surface → Task coordinator: reads task stats
packages/runtime/src/telemetry/runtime.ts