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

Add WebWorkerDedicatedExecutor to run actors on a dedicated web worker #297

Merged
merged 6 commits into from
Mar 14, 2025

Conversation

kateinoigakukun
Copy link
Member

@kateinoigakukun kateinoigakukun commented Mar 14, 2025

This PR introduces WebWorkerDedicatedExecutor, a new serial executor that runs on a dedicated Web Worker thread. This executor allows actors to run in their own isolated execution environment and provides an easier way to offload works.

actor MyActor {
    let executor: WebWorkerDedicatedExecutor
    nonisolated var unownedExecutor: UnownedSerialExecutor {
        self.executor.asUnownedSerialExecutor()
    }
    init(executor: WebWorkerDedicatedExecutor) {
        self.executor = executor
    }
}

let executor = try await WebWorkerDedicatedExecutor()
let actor = MyActor(executor: executor)

Copy link

github-actions bot commented Mar 14, 2025

Time Change: +523ms (5%) 🔍

Total Time: 10,095ms

Test name Duration Change
Serialization/JavaScript function call through Wasm import 26ms +2ms (6%) 🔍
Serialization/JavaScript function call through Wasm import with int 23ms +2ms (6%) 🔍
Serialization/JavaScript function call from Swift 136ms +15ms (11%) ⚠️
Serialization/Swift Int to JavaScript with call 1,020ms +59ms (5%) 🔍
Serialization/JavaScript Number to Swift Int 292ms +22ms (7%) 🔍
Serialization/Swift String to JavaScript with assignment 440ms +24ms (5%) 🔍
Serialization/Swift String to JavaScript with call 1,103ms +62ms (5%) 🔍
Serialization/JavaScript String to Swift String 3,873ms +288ms (7%) 🔍
View Unchanged
Test name Duration Change
Serialization/Swift Int to JavaScript with assignment 352ms +16ms (4%)
Object heap/Increment and decrement RC 2,812ms +30ms (1%)
View Baselines
Test name Duration
Serialization/Call JavaScript function directly 3ms
Serialization/Assign JavaScript number directly 4ms
Serialization/Call with JavaScript number directly 3ms
Serialization/Write JavaScript string directly 4ms
Serialization/Call with JavaScript string directly 4ms

@kateinoigakukun kateinoigakukun marked this pull request as ready for review March 14, 2025 12:04
@kateinoigakukun kateinoigakukun merged commit 28a40b7 into main Mar 14, 2025
7 checks passed
@kateinoigakukun kateinoigakukun deleted the yt/dedicated-executor branch March 14, 2025 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant