Skip to content

worker: motivating examples? #33880

Closed
Closed
@ronag

Description

@ronag

I'm having a hard time figuring out when I would actually want to use workers over a child process.

The docs provide the following motivation:

Unlike child_process or cluster, worker_threads can share memory. They do so by transferring ArrayBuffer instances or sharing SharedArrayBuffer instances.

However, I'm having a hard time finding a case where I would actually use this. Usually I would have either strings or objects that I would like to pass onto a worker. Maybe something like https://capnproto.org/ could take advantage of this? But from what I can see such approaches are actually quite slow in javascript.

Also, from what I understand actually transferring Buffers to workers have some edge cases and could fallback to become a copy.

I'm not saying it's a bad feature. I would really love to try it out and use it. I'm just having trouble finding the use case for it.

Maybe someone could provide some ideas/examples of when this would be useful would be helpful as a point of inspiration?

Metadata

Metadata

Assignees

No one assigned

    Labels

    docIssues and PRs related to the documentations.questionIssues that look for answers.workerIssues and PRs related to Worker support.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions