-
Notifications
You must be signed in to change notification settings - Fork 412
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
replace the current implementation with an unbounded number of workers Signed-off-by: Rudi Grinberg <me@rgrinberg.com>
- Loading branch information
Showing
18 changed files
with
218 additions
and
270 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
open Dune_thread_pool | ||
|
||
let spawn_thread f = ignore (Thread.create f ()) | ||
|
||
let%bench "almost no-op" = | ||
let tp = Thread_pool.create ~min_workers:10 ~max_workers:50 ~spawn_thread in | ||
let tasks = 50_000 in | ||
let counter = Atomic.make tasks in | ||
let f () = Atomic.decr counter in | ||
for _ = 0 to tasks - 1 do | ||
Thread_pool.task tp ~f | ||
done; | ||
while Atomic.get counter > 0 do | ||
Thread.yield () | ||
done | ||
|
||
let%bench "syscall" = | ||
let tp = Thread_pool.create ~min_workers:10 ~max_workers:50 ~spawn_thread in | ||
let tasks = 50_000 in | ||
let counter = Atomic.make tasks in | ||
let f () = | ||
Unix.sleepf 0.0; | ||
Atomic.decr counter | ||
in | ||
for _ = 0 to tasks - 1 do | ||
Thread_pool.task tp ~f | ||
done; | ||
while Atomic.get counter > 0 do | ||
Thread.yield () | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Inline_benchmarks_public.Runner.main ~libname:"thread_pool_bench" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.