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

single file benchmarks #1937

Merged
merged 1 commit into from
Apr 30, 2024
Merged

Conversation

Alizter
Copy link
Collaborator

@Alizter Alizter commented Apr 30, 2024

We add some dune rules to benchmark the compilation of single .v files. It works by writing (theories/file/to/bench.v) in a file called file_to_bench and running dune build @bench. This uses a program called hyperfine which must be available for this to work. After the bench is run it outputs a bench report.

Typical output:

$ dune build @bench
Starting bench. This may take a while.
Bench finished, report at bench_report:

Benchmark 1: /nix/store/v97xkrdzqhwrz8305w05vfix32y5qifa-coq-8.19.1/bin/coqc -R ./theories HoTT -noinit -indices-matter benched_file.v
  Time (mean ± σ):      6.421 s ±  0.024 s    [User: 6.202 s, System: 0.195 s]
  Range (min … max):    6.364 s …  6.461 s    10 runs

We add some dune rules to benchmark the compilation of single .v files.
It works by writing (theories/file/to/bench.v) in a file called
`file_to_bench` and running `dune build @bench`. This uses a program
called `hyperfine` which must be available for this to work. After the
bench is run it outputs a bench report.

Typical output:

```
[ali@allosaurus:~/HoTT]$ dune build @bench
Starting bench. This may take a while.
Bench finished, report at bench_report:

Benchmark 1: /nix/store/v97xkrdzqhwrz8305w05vfix32y5qifa-coq-8.19.1/bin/coqc -R ./theories HoTT -noinit -indices-matter benched_file.v
  Time (mean ± σ):      6.421 s ±  0.024 s    [User: 6.202 s, System: 0.195 s]
  Range (min … max):    6.364 s …  6.461 s    10 runs
```

Signed-off-by: Ali Caglayan <alizter@gmail.com>

<!-- ps-id: 9ddbc823-231a-471c-9eb2-ec07405c0998 -->
@Alizter Alizter mentioned this pull request Apr 30, 2024
Copy link
Collaborator

@jdchristensen jdchristensen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So there isn't a way to pass the name of the file on the command line? With make, we can tell it to do timing by setting some variables, and then use the usual mechanism to just build certain files: make TIMED=1 TIMING=1 path/to/file.vo

BTW, our make set-up has lots of timing options via the scripts in the coq-scripts repo. E.g. before and after comparisons of the whole library. And the line-by-line timing like at the link above. Can those things be done via dune? Currently I rebuild using make when I want to do timing.

@Alizter
Copy link
Collaborator Author

Alizter commented Apr 30, 2024

Dune isn't aware of the .timing files that get produced even if we pass -time to the general Coq flags. For it to be aware, I would have to modify Dune upstream so that we can have an "extra files" field for Coq compilation outputs. The .timing files are still being produced but you won't be able to write rules that depend on them since nobody would have told dune how these files are produced.

The timing makefile scripts are cool but they only really work for make. The same could be adapted to Dune but I don't see the point since it would be a lot of work. In those cases I would just use make. We could make some dune rules that run the makefile in an isolated environment so that it doesn't litter the source directory however.

@Alizter
Copy link
Collaborator Author

Alizter commented Apr 30, 2024

Oh, and I couldn't work out a way to pass the name via the command line, at least via the dune cli. If you like I can make a bash script in etc/ that takes in the name and updates the file dune is checking before running it.

@Alizter
Copy link
Collaborator Author

Alizter commented Apr 30, 2024

Also here is hyperfine: https://github.com/sharkdp/hyperfine

@jdchristensen
Copy link
Collaborator

It's fine to merge this as is. And I don't mind using make for the older timing scripts.

@Alizter Alizter merged commit e63addc into HoTT:master Apr 30, 2024
23 checks passed
@Alizter Alizter deleted the ps/rr/single_file_benchmarks branch April 30, 2024 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants