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

Weave as a background service #136

Merged
merged 17 commits into from
May 16, 2020
Merged

Weave as a background service #136

merged 17 commits into from
May 16, 2020

Conversation

mratsim
Copy link
Owner

@mratsim mratsim commented May 16, 2020

This is an experimental implementation of #132

Direct link to the readme: https://github.com/mratsim/weave/tree/8f9db32b71cb1e493c496d8afce44aba38f9d6c6#foreign-thread--background-service-experimental

Weave can now be started in a dedicated thread via runInBackground(Weave).

Jobs can be submitted to it and waited upon with submit fnCall(args) and waitFor(Pending).
To do that, a thread (unmanaged by Weave) must call setupSubmitterThread(Weave) and then waitUntilReady(Weave).

A job is different from a task in only small ways.

  • a job is called from a thread that Weave doesn't know about
  • jobs are processed in FIFO order to minimize latency while tasks are in LIFO order to maximize locality, cache reuse and throughput
  • jobs can spawn tasks (and tasks can spawn tasks). Concretely that means that
    when a job enters the runtime, work on a new job will wait for all subtasks to be processed unless the job does not spawn enough tasks to create work for all CPUs.

To ensure proper usage of submit/waitFor on submitter threads and spawn/sync within Weave tasks a distinct Pending type has been created with the same semantics as Flowvar.

In the future, submit/waitFor may be removed for an unified spawn/sync construct.

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