GithubHelp home page GithubHelp logo

choir's People

Contributors

kvark avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

choir's Issues

Task dependencies are not fully sound

Unfortunately try_unwrap can't be used for linear-ish Arc<Task> type finish line. This is because it returns Arc<Task>, which is then dropped anyway without any checks. So there is a race condition that could result in a dependent task not firing.
See rust-lang/rust#79665 for the solution that got closed (unfortunately) due to inactivity, also discussion on rust-internals.

Integrate Loom

See https://docs.rs/loom/latest/loom/
It's a magical tool to help debugging concurrency issues.
There is a small downside that this has to be a compile feature, and it's not useful to the outside (i.e. internal compile feature). But I think it's worth it anyway.

Remove Sync bound

Getting this funny error if I remove Sync:

    Checking choir v0.2.0 (/Users/kvark/Code/choir)
error[E0277]: `(dyn FnOnce() + Send + 'static)` cannot be shared between threads safely
   --> src/lib.rs:231:14
    |
231 |             .spawn(move || conductor.work_loop(&worker_clone))
    |              ^^^^^ `(dyn FnOnce() + Send + 'static)` cannot be shared between threads safely
    |
    = help: the trait `Sync` is not implemented for `(dyn FnOnce() + Send + 'static)`
    = note: required because of the requirements on the impl of `Sync` for `Unique<(dyn FnOnce() + Send + 'static)>`
    = note: required because it appears within the type `Box<(dyn FnOnce() + Send + 'static)>`
note: required because it appears within the type `Task`
   --> src/lib.rs:57:12
    |
57  | pub struct Task {
    |            ^^^^
    = note: required because of the requirements on the impl of `Send` for `Arc<Task>`
    = note: 1 redundant requirement hidden
    = note: required because of the requirements on the impl of `Send` for `Unique<Arc<Task>>`
    = note: required because it appears within the type `alloc::raw_vec::RawVec<Arc<Task>>`
    = note: required because it appears within the type `Vec<Arc<Task>>`
note: required because it appears within the type `Continuation`
   --> src/lib.rs:48:10
    |
48  | pub enum Continuation {
    |          ^^^^^^^^^^^^
    = note: required because of the requirements on the impl of `Sync` for `Mutex<Continuation>`
    = note: 1 redundant requirement hidden
    = note: required because of the requirements on the impl of `Send` for `Arc<Mutex<Continuation>>`
note: required because it appears within the type `Task`
   --> src/lib.rs:57:12
    |
57  | pub struct Task {
    |            ^^^^
    = note: required because of the requirements on the impl of `Sync` for `Injector<Task>`
note: required because it appears within the type `Conductor`
   --> src/lib.rs:76:8
    |
76  | struct Conductor {
    |        ^^^^^^^^^
    = note: required because of the requirements on the impl of `Send` for `Arc<Conductor>`
    = note: required because it appears within the type `[closure@src/lib.rs:231:20: 231:62]`
note: required by a bound in `Builder::spawn`

Threads going to sleep are sometimes not considered parked

When scheduling a task, the logic checks if any threads are parked, and tries to wake them up. It may happen that at this time the threads are just about to sleep, and they aren't sleeping yet, and their parked mask may or may not be updated. This leads to a freeze, where there is work but no threads are awake.

Child task forks semantics could be better

Currently, when forking a task, the child inherits all of the dependents.
This is generally useful, but can become a pitfall for the following cases:

  1. New dependents may appear at any moment, which would make forking a race against adding new dependents.
  2. join() doesn't know or care about forked tasks, so the parent will technically finish before the children.

Instead, it would seem natural to expect that all the children are opaque to the caller. Join() should wait for all, and dependents should be propagated to all, or simply shared.

Sequential test occasionally fails

     Running tests/basic.rs (target/debug/deps/basic-c693d3602fd57ec1)

running 6 tests
test child_tasks ... ok
test multi_sum ... ok
test iter_xor ... ok
test parallel ... ok
test zero_count ... ok
test sequential ... FAILED

failures:

---- sequential stdout ----
thread 'sequential' panicked at 'assertion failed: `(left == right)`
  left: `38`,
 right: `100`', tests/basic.rs:52:5

Hang in join()

Sometimes all workers finish their tasks but the caller thread's join() doesn't return. Happened on the parallel test once.

Detach task scheduling from waking up threads

The benchmark of running N individual tasks on 2 workers is currently entering this weird state where:

  • both workers are mostly parked/sleeping
  • schedule() take a long time since it repeatedly tries to wake up one of them until it grabs the task
  • this makes the main thread unable to saturate the queue

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.