V8-based JavaScript runtime for serverless workers, built on rusty_v8.
use openworkers_runtime_v8::{
init_pinned_pool, execute_pinned,
PinnedPoolConfig, PinnedExecuteRequest, RuntimeLimits,
};
// Initialize pool once at startup
init_pinned_pool(PinnedPoolConfig {
max_per_thread: 100,
max_per_owner: Some(10),
max_concurrent_per_isolate: 1,
max_cached_contexts: 5,
limits: RuntimeLimits::default(),
});
// Execute worker
execute_pinned(PinnedExecuteRequest {
owner_id: "tenant-1".into(),
worker_id: "worker-1".into(),
version: 1,
script,
ops,
task: event,
on_warm_hit: None,
env_updated_at: None,
}).await?;Thread-local isolate pool with per-owner isolation and warm context caching.
PinnedPoolConfig::max_concurrent_per_isolate sets how many requests an isolate
serves at once: 1 gives each request the isolate to itself, and more lets
requests share it through the AsyncWaiter fair FIFO queue.
Fresh isolate per request. No caching, no Locker. Best for debugging or maximum security.
let mut worker = Worker::new_with_ops(script, limits, ops).await?;
worker.exec(event).await?;| Mode | Cold Start | Warm Start |
|---|---|---|
| Pinned Pool | Tens of µs | Sub-µs |
| Worker | Few ms | Few ms |
- Isolate pooling with LRU context caching
- Streaming with ReadableStream and backpressure
- Web APIs — fetch, setTimeout, Response, Request, URL, console
- Async/await — Full Promise support
- Code cache — V8 code cache for faster cold starts
# From openworkers-runner (not this crate directly)
cargo test --features v8MIT