Simon Cruanes
d4e5e811bb
breaking: fut: change behavior of ?on
...
combinators that take `?on` will now check if they can use the current
runner if `?on:None` is passed. If no runner is passed and they're run
from outside a runner, they will just run in the relevant callback or on
the current thread.
2023-11-08 12:02:13 -05:00
Simon Cruanes
9709f88d5f
breaking: fut: join does not take ?on anymore
2023-11-08 12:02:13 -05:00
Simon Cruanes
9cb7781a2e
feat: fut: add spawn_on_current_runner
2023-11-08 12:02:13 -05:00
Simon Cruanes
0a432585c6
fix: in WS_pool, only schedule in worker queues in some cases
...
only do it if we actually want to spawn the task on pool A while running
on a worker of A (not a worker on B).
2023-11-08 12:02:13 -05:00
Simon Cruanes
245bfd9b7b
test: regression test for bug
2023-11-08 12:02:13 -05:00
Simon Cruanes
d2be2db0ef
perf fork-join: in both f g only run f in the background
...
`g` can run immediately on same thread, otherwise we just suspend the
computation and start a new task for nothing.
2023-11-08 11:38:15 -05:00
Simon Cruanes
6e6a2a1faa
feat runner: add get_current_runner
...
this relies on TLS to access the current pool really quickly.
2023-11-08 11:38:15 -05:00
Simon Cruanes
6fe7076099
update doc and readme
2023-11-08 11:36:10 -05:00
Simon Cruanes
2073c600c4
add Moonpool.run_async
2023-11-08 11:36:10 -05:00
Simon Cruanes
72f289af84
refactor: use a fixed size work-stealing deque
...
if it's full, tasks overflow into the main queue.
2023-11-08 11:36:10 -05:00
Simon Cruanes
80031c0a54
fix compilation error
2023-11-08 09:41:57 -05:00
Simon Cruanes
00a5cfc8ba
fix: rename Thread_local_storage_ to not collide with the library
2023-11-08 09:41:57 -05:00
Simon Cruanes
928345437a
fix tests to use new API
2023-11-08 09:41:57 -05:00
Simon Cruanes
133a0d6128
breaking: change interface for number of threads
...
now the user can specify `num_threads`; if not provided a sensible
default is picked.
2023-11-08 09:41:57 -05:00
Simon Cruanes
21ac980fb2
rename no_runner to immediate_runner
2023-11-08 09:41:57 -05:00
Simon Cruanes
056f80b318
add No_runner: a runner that doesn't do anything in the background
...
The idea is that you might have APIs that want a runner, but the work is
too trivial to require a full actual thread pool. In this case use
`No_runner.runner` and calls to `run_async runner f` will turn into `f()`.
2023-11-08 09:41:57 -05:00
Simon Cruanes
a3d3468b5e
feat: add Moonpool.recommended_thread_count
2023-11-08 09:41:57 -05:00
Simon Cruanes
7a36783e8b
perf: also use the main domain, along with n-1 other ones
...
we always keep a thread alive on the main domain as a worker for new
tasks, but other domains can still come and go to manage resources
properly in case a pool is started and used only for a short while.
2023-11-08 09:41:57 -05:00
Simon Cruanes
def384b4f8
fix warning
2023-10-27 16:18:24 -04:00
Simon Cruanes
052b70027a
compat 4.08
2023-10-27 16:17:56 -04:00
Simon Cruanes
bfcf7f774e
chore: handpick combinations for bench-pi
2023-10-27 16:16:49 -04:00
Simon Cruanes
ddf394be90
chore: handpick set of benchmarks
2023-10-27 16:06:55 -04:00
Simon Cruanes
aba0d84ecf
ws pool: random stealing; rework main state machine
...
in the state machine, after waiting, we check the main queue, else we
directly go to stealing.
2023-10-27 16:05:52 -04:00
Simon Cruanes
aa7906eb2c
perf TLS: inline
2023-10-27 16:05:43 -04:00
Simon Cruanes
e67bffeca5
ws_pool: use TLS for quick worker storage access; reduce contention
2023-10-27 15:18:50 -04:00
Simon Cruanes
b4ddd82ee8
ws pool: use non atomic boolean to reduce number of wakeups; refactor
2023-10-27 14:48:13 -04:00
Simon Cruanes
359ec0352b
small change to test
2023-10-27 14:47:59 -04:00
Simon Cruanes
68fe7221b8
suspend: remove additional parameter, always run tasks in handler
2023-10-27 14:47:54 -04:00
Simon Cruanes
9e0a583a94
chore: disable -dl/-seq benchs for now, too verbose
2023-10-27 14:46:59 -04:00
Simon Cruanes
c044fb8fc9
tweal to WS pool
2023-10-27 12:26:50 -04:00
Simon Cruanes
08722691e8
ws deque: try to reduce false sharing
2023-10-27 12:26:43 -04:00
Simon Cruanes
9e93ebd3bb
update benchmark fib-rec with more implementations
2023-10-27 12:26:03 -04:00
Simon Cruanes
5409cf8e1b
compat 4.08
2023-10-25 23:50:34 -04:00
Simon Cruanes
3e614ec992
rename Pool to Ws_pool; deprecated Moonpool.Pool
2023-10-25 23:43:18 -04:00
Simon Cruanes
30035fa67d
fix pool: suspension handler might run from a different thread!
...
this means we can't reuse the same worker state, it's neither thread
safe nor deadlock-safe (the worker whose state it is might be waiting on
the main queue)
2023-10-25 23:30:04 -04:00
Simon Cruanes
1e3629bc67
fix ws_deque: strict bound for shrinking
2023-10-25 23:29:47 -04:00
Simon Cruanes
629b66662f
fix ws_deque: circular array is also in an atomic
2023-10-25 23:18:47 -04:00
Simon Cruanes
1ed25e5aca
test: make t_ws_deque consume less ram
2023-10-25 22:41:26 -04:00
Simon Cruanes
dfb588cdc5
test: update readme
2023-10-25 22:41:18 -04:00
Simon Cruanes
056986c84f
perf pool: no retries for self-queue; fewer retries for stealing
2023-10-25 22:38:43 -04:00
Simon Cruanes
e937bf0e9d
perf pool: restore non-hashtable lookup for self-queuing
2023-10-25 22:38:35 -04:00
Simon Cruanes
3956fb6566
fix ws_pool: no work stealing for pools of 1 worker
...
there would be a loop because it'd try to find the index of another
worker to steal from, but loop forever because there is no other worker.
2023-10-25 22:33:08 -04:00
Simon Cruanes
d9da7844e2
test: run more diverse pools in t_fib_rec
2023-10-25 22:32:57 -04:00
Simon Cruanes
894851f6e8
comments in ws_deque
2023-10-25 22:32:42 -04:00
Simon Cruanes
530507d84e
fix fifo_pool: raise Shutdown, not Closed, in run
2023-10-25 22:11:08 -04:00
Simon Cruanes
3f720241b2
feat pool: use Shutdown when running a task after it's closed
2023-10-25 22:10:10 -04:00
Simon Cruanes
9a1309c44f
chore: add keywords in opam
2023-10-25 22:03:35 -04:00
Simon Cruanes
a89c0ce4f2
breaking: make Runner.t abstract
2023-10-25 21:59:22 -04:00
Simon Cruanes
6452ca89d1
rename Simple_pool into Fifo_pool, update doc
2023-10-25 21:55:29 -04:00
Simon Cruanes
db33bec13f
wip: better work stealing pool
2023-10-25 12:11:41 -04:00