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

Use task pool instead of handwritten implementation #6

Merged
merged 2 commits into from Apr 12, 2020

Conversation

kayceesrk
Copy link
Contributor

No description provided.

@athas
Copy link
Owner

athas commented Apr 12, 2020

This code does not compile for me:

+ ocamlfind ocamlc -c -g -bin-annot -package domainslib -o ray.cmo ray.ml
File "ray.ml", line 1, characters 14-29:
Error: Unbound module Domainslib.Task
Command exited with code 2.

@kayceesrk
Copy link
Contributor Author

Can you check domainslib version? opam list domainslib. It should be 0.2.0. To upgrade, please do:

$ opam update
$ opam install domainslib.0.2.0

@athas
Copy link
Owner

athas commented Apr 12, 2020

It works! And it's a bit faster, too.

@athas athas merged commit d1402c8 into athas:master Apr 12, 2020
athas added a commit that referenced this pull request Apr 12, 2020
@kayceesrk
Copy link
Contributor Author

Great. I'm happy that all the boilerplate is now gone.

@rand00
Copy link
Contributor

rand00 commented Apr 12, 2020

Cool that the task interface fits the problems here! I'm wondering if it would make sense to make the pool of size num_domains? The main domain is just waiting for the others to finish work?

@kayceesrk
Copy link
Contributor Author

kayceesrk commented Apr 12, 2020

Cool that the task interface fits the problems here! I'm wondering if it would make sense to make the pool of size num_domains? The main domain is just waiting for the others to finish work?

The main domain does participate in working on tasks. For example, you can create a pool with num_domains as 0; 0 indicates the number of additional domains. I'll clarify this in the API docs.

@rand00
Copy link
Contributor

rand00 commented Apr 12, 2020

Ah cool

@rand00
Copy link
Contributor

rand00 commented Apr 12, 2020

Just had a look at Domainslib.Task.setup_pool - there is only spawned a worker per num_domains - so the only work the main domain does is the work up until one calls Task.await pool <foo>, if <foo> contains a recursive call to the same function, correct?

@rand00
Copy link
Contributor

rand00 commented Apr 12, 2020

Ah sorry - it's await that also is a worker

@kayceesrk
Copy link
Contributor Author

Yeah. The idea is to set up the pool (which essentially sets up a shared channel as a work-stealing queue). The worker domains first wait on the channel for tasks and execute them when one is available. And as you've observed, await waits for task completion, but also continues to process tasks.

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.

None yet

3 participants