Skip to content

Commit f9aa37a

Browse files
authored
Benchmarks: move version-specific set-up from docker file to makefiles (#1927)
* Benchmarks: move version-specific set-up from docker file to makefiles * Partial render table: Compile as much as possible during docker build * Output timing information
1 parent bed6548 commit f9aa37a

File tree

8 files changed

+35
-29
lines changed

8 files changed

+35
-29
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ _build
44
compiler/tests-*
55
manual
66
examples
7+
benchmarks/build

bench.Dockerfile

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -34,35 +34,20 @@ RUN mkdir janestreet \
3434

3535
# Install dependencies
3636
WORKDIR /bench-dir/js_of_ocaml
37-
COPY --chown=opam:opam ./*.opam ./
38-
RUN opam pin -yn --with-version=dev .
39-
RUN opam install -y --deps-only js_of_ocaml-compiler \
40-
&& opam install opam-format stringext uucp cstruct bigstringaf \
37+
COPY --chown=opam:opam js_of_ocaml-compiler.opam .
38+
RUN opam install -y --deps-only ./js_of_ocaml-compiler.opam \
39+
&& opam install opam-format stringext uucp cstruct \
4140
&& opam clean
4241

43-
# Install js_of_ocaml / wasm_of_ocaml
44-
COPY --chown=opam:opam . ./
45-
RUN opam install -y wasm_of_ocaml-compiler \
46-
&& opam clean
47-
48-
# Compile partial render table benchmark
49-
#RUN opam exec -- dune exec tools/ci_setup.exe ../janestreet . \
50-
# && opam install ppxlib.0.35.0 # temporary workaround \
51-
# && opam clean
52-
42+
# Prepare partial render table benchmark
43+
COPY --chown=opam:opam dune-project ./
44+
COPY --chown=opam:opam tools ./tools
5345
RUN opam exec -- dune exec tools/ci_setup.exe ../janestreet . \
54-
&& opam install ppxlib.0.35.0 \
55-
&& eval $(opam env) \
56-
&& dune build --root ../janestreet --profile release lib/bonsai_web_components/partial_render_table/bench/bin/main.bc.wasm.js lib/bonsai_web_components/partial_render_table/bench/bin/main.bc.js \
57-
&& cp -r ../janestreet/_build/default/lib/bonsai_web_components/partial_render_table/bench/bin/main.bc* ./benchmarks/benchmark-partial-render-table/ \
58-
&& rm -rf ../janestreet
46+
&& opam exec -- dune build --root ../janestreet --profile release lib/bonsai_web_components/partial_render_table/bench/bin/main.bc-for-jsoo \
47+
&& opam remove js_of_ocaml-compiler ojs \
48+
&& opam clean
5949

60-
# CAMLBOY
61-
WORKDIR /bench-dir
62-
RUN opam install brr \
63-
&& opam clean \
64-
&& git clone --depth 1 https://github.com/ocaml-wasm/CAMLBOY -b node \
65-
&& cd CAMLBOY \
66-
&& opam exec -- dune build --root . --profile release ./bin/web
50+
# Copy sources
51+
COPY --chown=opam:opam . ./
6752

6853
WORKDIR /bench-dir/js_of_ocaml/benchmarks

benchmarks/Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,25 @@ all: _perf graphsnopr graphspr graphseff _noperf
1414
# see https://github.com/ocurrent/current-bench
1515
.PHONY: bench microbenchmarks
1616
bench:
17+
@date -u +"%FT%TZ - Installing dependencies"
18+
opam pin -yn --with-version=dev ..
19+
opam install -y wasm_of_ocaml-compiler js_of_ocaml-ppx gen_js_api brr
1720
$(MAKE) microbenchmarks
1821
$(MAKE) -C benchmark-fiat-crypto bench
1922
$(MAKE) -C benchmark-ocamlc bench
2023
$(MAKE) -C benchmark-partial-render-table bench
2124
$(MAKE) -C benchmark-camlboy bench
2225

2326
microbenchmarks:
27+
@date -u +"%FT%TZ - Microbenchmarks: starting"
2428
make _noprecomp
29+
@date -u +"%FT%TZ - Microbenchmarks: compiler"
2530
$(RUN) ./report-wasm-cb.config ./report-jsoo-cb.config
2631
$(REPORT) -format current-bench -config report-wasm-cb.config \
2732
-ylabel "Wasm_of_ocaml" | sh utils/aggregate.sh wasm
2833
$(REPORT) -format current-bench -config report-jsoo-cb.config \
2934
-ylabel "Js_of_ocaml" | sh utils/aggregate.sh js
35+
@date -u +"%FT%TZ - Microbenchmarks: done"
3036

3137
graphsnopr: _noprecomp $(GRAPHSNOPR)
3238

benchmarks/benchmark-camlboy/Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,18 @@ export NAME=Camlboy
44

55
SHELL=/bin/bash -o pipefail
66

7-
DIR=../../../CAMLBOY
7+
DIR=CAMLBOY
88
SCRIPT=$(DIR)/_build/default/bin/web/bench_node.bc
99
ROM=$(DIR)/resource/games/tobu.gb
1010

1111
bench:
12+
@date -u +"%FT%TZ - $(NAME): starting"
13+
git clone --depth 1 https://github.com/ocaml-wasm/CAMLBOY -b node
14+
cd $(DIR) && opam exec -- dune build --root . --profile release ./bin/web
15+
@date -u +"%FT%TZ - $(NAME): compiled"
1216
$(MAKE) perform COMPILER=Js_of_ocaml SUFFIX=.js KIND=js
1317
$(MAKE) perform COMPILER=Wasm_of_ocaml SUFFIX=.wasm.js KIND=wasm
18+
@date -u +"%FT%TZ - $(NAME): done"
1419

1520
perform:
1621
node $(SCRIPT)$(SUFFIX) $(ROM) | \

benchmarks/benchmark-fiat-crypto/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ export NAME=Fiat-Crypto
55
SHELL=/bin/bash -o pipefail
66

77
bench:
8+
@date -u +"%FT%TZ - $(NAME): starting"
89
$(MAKE) perform COMPILER=js_of_ocaml EXTRA_ARGS="--enable effects" KIND=js
910
$(MAKE) perform COMPILER=wasm_of_ocaml EXTRA_ARGS="" KIND=wasm
11+
@date -u +"%FT%TZ - $(NAME): done"
1012

1113
perform: bedrock2_fiat_crypto.byte
1214
/usr/bin/time -f "%E %R" $(COMPILER) --debug times --source-map $(EXTRA_ARGS) $< 2>&1 | \

benchmarks/benchmark-ocamlc/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ export NAME=Ocamlc
55
SHELL=/bin/bash -o pipefail
66

77
bench:
8+
@date -u +"%FT%TZ - $(NAME): starting"
89
cp -r ../sources/ml .
910
$(MAKE) perform COMPILER=js_of_ocaml SCRIPT=ocamlc.js KIND=js
1011
$(MAKE) perform COMPILER=wasm_of_ocaml SCRIPT=ocamlc.wasm.js KIND=wasm
12+
@date -u +"%FT%TZ - $(NAME): done"
1113

1214
ARGS=ml/*.ml ml/*.ml ml/*.ml ml/*.ml ml/*.ml ml/*.ml ml/*.ml ml/*.ml
1315

@@ -18,4 +20,3 @@ perform:
1820
/usr/bin/time -f '{"compiler": "$(COMPILER)", "time":"%E"}' node $(SCRIPT) -c $(ARGS) 2>&1 | \
1921
sh ../utils/format_metrics.sh exec | \
2022
sh ../utils/aggregate.sh $(KIND)
21-

benchmarks/benchmark-partial-render-table/Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,13 @@ export NAME=Partial Render Table
55
SHELL=/bin/bash -o pipefail
66

77
bench:
8+
@date -u +"%FT%TZ - $(NAME): starting"
9+
dune build --root ../../../janestreet --profile release lib/bonsai_web_components/partial_render_table/bench/bin/main.bc.wasm.js lib/bonsai_web_components/partial_render_table/bench/bin/main.bc.js
10+
cp -r ../../../janestreet/_build/default/lib/bonsai_web_components/partial_render_table/bench/bin/main.bc* .
11+
@date -u +"%FT%TZ - $(NAME): compiled"
812
$(MAKE) perform COMPILER=js_of_ocaml SCRIPT=main.bc.js KIND=js
913
$(MAKE) perform COMPILER=wasm_of_ocaml SCRIPT=main.bc.wasm.js KIND=wasm
14+
@date -u +"%FT%TZ - $(NAME): done"
1015

1116
perform:
1217
/usr/bin/time -f "%E %R" $(COMPILER) --debug times --opt 2 --pretty main.bc-for-jsoo -o out.js 2>&1 | \

benchmarks/report.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,8 @@ let current_bench_output
326326
let json =
327327
`Assoc [ "name", `String suite_name; "results", `List (summary :: results) ]
328328
in
329-
Yojson.Basic.to_channel ch json
329+
Yojson.Basic.to_channel ch json;
330+
output_char ch '\n'
330331

331332
let output ~format conf =
332333
let output_function, close =

0 commit comments

Comments
 (0)