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

Add microbenchmarks for the scheduler #1291

Merged
5 commits merged into from Sep 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ next

- Support colors on Windows (#1290, @diml)

- Allow `dune.configurator` and `base` to be used together (#1291, fix
#1167, @diml)

1.2.1 (17/09/2018)
------------------

Expand Down
11 changes: 11 additions & 0 deletions bench/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
(library
(name dune_bench)
(libraries stdune fiber dune)
(modules :standard \ main)
(library_flags -linkall)
(preprocess (pps ppx_bench)))

(executable
(name main)
(modules main)
(libraries which_program_dune dune_bench core_bench.inline_benchmarks))
1 change: 1 addition & 0 deletions bench/main.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Inline_benchmarks_public.Runner.main ~libname:"dune_bench"
4 changes: 4 additions & 0 deletions bench/runner.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
export BENCHMARKS_RUNNER=TRUE
export BENCH_LIB=dune_bench
exec dune exec -- ./main.exe -fork -run-without-cross-library-inlining "$@"
21 changes: 21 additions & 0 deletions bench/scheduler_bench.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
(* Benchmark the scheduler *)

open Stdune
open Dune

let () =
Path.set_root (Path.External.cwd ());
Path.set_build_dir (Path.Kind.of_string "_build")

let prog = Option.value_exn (Bin.which "true")
let run () = Process.run ~env:Env.initial Strict prog []

let go ~jobs fiber =
Scheduler.go fiber ~config:{ Config.default with concurrency = Fixed jobs }

let%bench "single" = go (run ()) ~jobs:1

let l = List.init ~len:100 ~f:ignore

let%bench "many" [@indexed jobs = [1; 2; 4; 8]] =
go ~jobs (Fiber.parallel_iter l ~f:run)
2 changes: 1 addition & 1 deletion bootstrap.ml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ end
(* Directories with library names *)
let dirs =
[ "src/which_program" , Some "Which_program"
; "src/stdune/caml" , Some "Caml"
; "src/stdune/caml" , Some "Dune_caml"
; "src/stdune" , Some "Stdune"
; "src/fiber" , Some "Fiber"
; "src/xdg" , Some "Xdg"
Expand Down
2 changes: 1 addition & 1 deletion src/dune
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
stdune
fiber
xdg
re
dune_re
opam_file_format
dsexp
ocaml_config
Expand Down
2 changes: 1 addition & 1 deletion src/glob_lexer.boot.ml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
let parse_string _ = failwith "globs are not available during bootstrap"

(* To force the ordering during bootstrap *)
let _ = Re.compile
let _ = Dune_re.compile
2 changes: 1 addition & 1 deletion src/glob_lexer.mli
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
open Stdune

val parse_string : string -> (Re.t, int * string) Result.result
val parse_string : string -> (Dune_re.t, int * string) Result.result
1 change: 1 addition & 0 deletions src/glob_lexer.mll
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
open! Stdune
module Re = Dune_re
open Re

let no_slash = diff any (char '/')
Expand Down
2 changes: 2 additions & 0 deletions src/import.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ open! Stdune
include Stdune
include Errors

module Re = Dune_re

(* To make bug reports usable *)
let () = Printexc.record_backtrace true

Expand Down
4 changes: 2 additions & 2 deletions src/stdune/bytes.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
include StdLabels.Bytes

let blit_string ~src ~src_pos ~dst ~dst_pos ~len =
Caml.Bytes.blit_string src src_pos dst dst_pos len
Dune_caml.Bytes.blit_string src src_pos dst dst_pos len

let sub_string dst ~pos ~len =
Caml.Bytes.sub_string dst pos len
Dune_caml.Bytes.sub_string dst pos len
2 changes: 1 addition & 1 deletion src/stdune/caml/dune
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(library
(name caml)
(name dune_caml)
(public_name dune._caml)
(synopsis "[Internal] Wrapped version of the OCaml stdlib"))
File renamed without changes.
2 changes: 1 addition & 1 deletion src/stdune/char.ml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Char = Caml.Char
module Char = Dune_caml.Char

include struct
[@@@warning "-32-3"]
Expand Down
2 changes: 1 addition & 1 deletion src/stdune/dune
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
(name stdune)
(public_name dune._stdune)
(synopsis "[Internal] Standard library of Dune")
(libraries caml unix))
(libraries dune_caml unix))
2 changes: 1 addition & 1 deletion src/stdune/filename.ml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include Caml.Filename
include Dune_caml.Filename

(* Return the index of the start of the extension, using the same semantic as
[Filename.extension] in 4.04 *)
Expand Down
2 changes: 1 addition & 1 deletion src/stdune/filename.mli
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include module type of struct include Caml.Filename end
include module type of struct include Dune_caml.Filename end

val split_extension : string -> string * string
val split_extension_after_dot : string -> string * string
Expand Down
2 changes: 1 addition & 1 deletion src/stdune/result.ml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type ('a, 'error) t = ('a, 'error) Caml.result =
type ('a, 'error) t = ('a, 'error) Dune_caml.result =
| Ok of 'a
| Error of 'error

Expand Down
2 changes: 1 addition & 1 deletion src/stdune/result.mli
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(** Result type *)

type ('a, 'error) t = ('a, 'error) Caml.result =
type ('a, 'error) t = ('a, 'error) Dune_caml.result =
| Ok of 'a
| Error of 'error

Expand Down
2 changes: 1 addition & 1 deletion src/stdune/string.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(* Because other the syntax s.[x] causes trouble *)
module String = Caml.String
module String = Dune_caml.String

include struct
[@@@warning "-32-3"]
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions vendor/cmdliner/src/dune
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(library
(name cmdliner)
(libraries caml)
(libraries dune_caml)
(wrapped false)
(flags (-w -3-6-27-32-33-35-50 -open Caml)))
(flags (-w -3-6-27-32-33-35-50 -open Dune_caml)))
4 changes: 3 additions & 1 deletion vendor/re/src/dune
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
(library
(name re)
(name dune_re)
(flags (:standard -w -50))
(synopsis "Internal Dune library, do not use!"))

(rule (with-stdout-to dune_re.ml (echo "include Re")))