Commit graph

234 commits

Author SHA1 Message Date
Simon Cruanes
c8e99fd7ee
cleanup 2024-02-11 16:40:15 -05:00
Simon Cruanes
e9c09406ba
feat: add structured concurrency moonpool.fib 2024-02-11 16:40:14 -05:00
Simon Cruanes
13d26783c7
fix 2024-02-11 16:40:14 -05:00
Simon Cruanes
44c155751c
fix 2024-02-11 16:40:14 -05:00
Simon Cruanes
e8cc87f1f5
fixes 2024-02-11 16:40:14 -05:00
Simon Cruanes
65fd89708e
add task_local_storage to core, modify how suspend works 2024-02-11 16:40:14 -05:00
Simon Cruanes
2f11fd75df
feat: add Exn_bt to core 2024-02-11 16:40:14 -05:00
Simon Cruanes
b8ce0c9fe3
make moonpool.forkjoin optional (only on OCaml >= 5.0) 2024-02-11 16:40:14 -05:00
Simon Cruanes
49c6cd3f53
doc 2024-02-11 16:40:14 -05:00
Simon Cruanes
e14fef2834
remove deprecated Moonpool.Pool 2024-02-11 16:39:44 -05:00
Simon Cruanes
223f22a0d9
breaking: move fork-join into sub-library moonpool.forkjoin 2024-02-11 16:39:44 -05:00
Simon Cruanes
37c42b68bc
fix 2024-02-11 16:39:44 -05:00
Simon Cruanes
b0fe279f42
more internal refactor 2024-02-11 16:39:44 -05:00
Simon Cruanes
cc8860c6e3
split into moonpool.private and moonpool; format; remove DLA 2024-02-11 16:39:43 -05:00
Simon Cruanes
381a775d28
fix some @since tags 2024-02-09 10:07:09 -05:00
Simon Cruanes
e56dbc6a09
fix build 2024-02-07 15:49:01 -05:00
Simon Cruanes
27b213e30f
tracing: add optional name for pools 2024-02-07 13:31:48 -05:00
Simon Cruanes
8d83d5b691
perf: reduce size of Fut again 2024-01-30 17:06:20 -05:00
Simon Cruanes
4abc334ab3
fix 2024-01-30 16:38:31 -05:00
Simon Cruanes
8e9564a6f7
compat 2024-01-30 16:26:29 -05:00
Simon Cruanes
ef7d370060
more tracing for Fut 2024-01-30 16:25:31 -05:00
Simon Cruanes
092ad5f2ce
feat: support for trace as a depopt
one can now give tasks an optional string "name". If `Trace`
is present (installed) and enabled, this results in
a span around the task's execution. This also plays ok
with `await` and other effect-based primitives.
2024-01-30 16:10:11 -05:00
Simon Cruanes
469cb89ecd
feat: add Fut.Advanced.barrier_on_abstract_container_of_futures
this is a good building block for waiting on multiple futures.
2023-12-22 13:14:05 -05:00
Simon Cruanes
2d306c91b2
fix too early exit in Ws_pool
when shutting down the pool, workers should check `self.active`
only when they have no local task, failed to steal tasks,
and found the main queue to be empty. Basically we check `self.active`
only just before we wait on the condition.
2023-11-24 23:12:22 -05:00
Simon Cruanes
1c94c59d88
feat: add Fut.map_list 2023-11-17 12:41:29 -05:00
Simon Cruanes
fd2102c7fe
prepare for 0.5 2023-11-08 12:38:40 -05:00
Simon Cruanes
3f7ed7b6b8 moonpool: expose Fut.{spawn_on_current_runner,await} 2023-11-08 12:02:13 -05:00
Simon Cruanes
59ae1068fd breaking: fut: only have module Infix
we keep `Infix_local` as a deprecated alias to it for now
2023-11-08 12:02:13 -05:00
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
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
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
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