Skip to content
Open
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
10 changes: 10 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,16 @@ jobs:
git diff --ignore-cr-at-eol --exit-code \
unison-src/transcripts-manual/dll-ffi-win.output.md

- name: benchmark smoke tests
# benchmarks hang on Windows
if: steps.cache-transcript-test-results.outputs.cache-hit != 'true' && runner.os != 'Windows'
run: |
${{env.ucm}} transcript unison-src/transcripts-manual/benchmarks.md

# Fail if the output or generated docs differ.
git diff --ignore-cr-at-eol --exit-code \
unison-src/transcripts-manual/benchmarks.md

- name: mark transcripts as passing
if: steps.cache-transcript-test-results.outputs.cache-hit != 'true'
run: |
Expand Down
2 changes: 1 addition & 1 deletion development.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Some tests are executables instead:
* `stack exec transcripts -- prefix-of-filename` runs only transcript tests with a matching filename prefix.
* `stack exec cli-integration-tests` runs the additional integration tests for cli. These tests are not triggered by `tests` or `transcripts`.
* `stack exec unison -- transcript unison-src/transcripts-round-trip/main.md` runs the pretty-printing round trip tests
* `stack exec unison -- transcript unison-src/transcripts-manual/benchmarks.md` runs the benchmark suite. Output goes in unison-src/transcripts-manual/benchmarks/output.txt.
* `sudo ./scripts/benchmark` runs the benchmark suite. (If you can’t or won’t run under `sudo` it will just run with lower scheduling priority)

### Building everything at once, including tests and benchmarks, but without running them:
Do:
Expand Down
19 changes: 19 additions & 0 deletions scripts/benchmark
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash
set -euo pipefail
SCRIPTDIR="$(dirname -- "$(readlink -f -- "${BASH_SOURCE[0]}")")"

### Run the Unison benchmark suite.
###
### NB: If run as a superuser (e.g., under `sudo`), this will use a higher priority to hopefully get more stable
### results.

## TODO: `transcripts` should be able to take a search path, but since it currently looks for files relative to its run
## path, we `cd` to where it can find them.
cd "$SCRIPTDIR/.."

niceness=0
if [[ $EUID -eq 0 ]]; then
niceness=-20
fi

nice -n $niceness stack exec unison -- transcript unison-src/transcripts-manual/benchmarks.md
93 changes: 2 additions & 91 deletions unison-src/transcripts-manual/benchmarks.md
Original file line number Diff line number Diff line change
@@ -1,96 +1,7 @@
``` ucm :hide
> pull unison.public.base.releases.M4d base
> pull runarorama.public.sort.data sort
```

``` unison :hide
benchmarkFilePath = FilePath "unison-src/transcripts-manual/benchmarks/output.bench.txt"
archiveFilePath = FilePath "unison-src/transcripts-manual/benchmarks/output"

timeit : Text -> '{IO,Exception} a ->{IO,Exception} a
timeit label a =
before = !realtime
r = !a
after = !realtime
elapsed = Duration.between before after
elapsedText = Duration.toText elapsed
go file =
putText file ("\n" ++ label ++ " " ++ Int.toText (Duration.countMicroseconds elapsed) ++ " # " ++ elapsedText)
printLine ("\n\n ******** \n")
printLine (label ++ " took " ++ elapsedText)
bracket '(FilePath.open benchmarkFilePath FileMode.Append) Handle.close go
r

prepare = do
-- if benchmarkFilePath exists, move it to blah-<datetime>.txt for archive purposes
use Text ++
if FilePath.exists benchmarkFilePath then
createDirectory archiveFilePath
now = OffsetDateTime.toText (atUTC !realtime)
timestamped = FilePath.toText archiveFilePath ++ "/" ++ now ++ "-bench.txt"
renameFile benchmarkFilePath (FilePath timestamped)
else
()
```

``` ucm :hide
> add
> run prepare
```

## Benchmarks

``` ucm
> load unison-src/transcripts-manual/benchmarks/each.u
> run main
```

``` ucm
> load unison-src/transcripts-manual/benchmarks/listmap.u
> run main
```

``` ucm
> load unison-src/transcripts-manual/benchmarks/listfilter.u
> run main
```

``` ucm
> load unison-src/transcripts-manual/benchmarks/random.u
> run main
```

``` ucm
> load unison-src/transcripts-manual/benchmarks/simpleloop.u
> run main
```

``` ucm
> load unison-src/transcripts-manual/benchmarks/fibonacci.u
> run main
```

``` ucm
> load unison-src/transcripts-manual/benchmarks/map.u
> run main
```

``` ucm
> load unison-src/transcripts-manual/benchmarks/natmap.u
> run main
```

``` ucm
> load unison-src/transcripts-manual/benchmarks/stm.u
> run main
```

``` ucm
> load unison-src/transcripts-manual/benchmarks/tmap.u
> run main
> pull @pchiusano/misc-benchmarks
```

``` ucm
> load unison-src/transcripts-manual/benchmarks/array-sort.u
> run main
> run suite
```
9 changes: 9 additions & 0 deletions unison-src/transcripts-manual/benchmarks.output.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
``` ucm :hide
> pull @pchiusano/misc-benchmarks
Copy link
Contributor

Choose a reason for hiding this comment

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

If there's a particular release of this that we want to pull that would probably be good; if there isn't a release, then let me or Paul know.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are currently no releases of @pchiusano/misc-benchmarks.

Copy link
Contributor

@aryairani aryairani Jan 21, 2026

Choose a reason for hiding this comment

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

@pchiusano Can you create a release of https://share.unison-lang.org/@pchiusano/misc-benchmarks and then tag @sellout

(Unless there's some reason why we don't care about those benchmarks.)

And also if you're in there is it appropriate and easy to change Value.serialize_v4 usages to v5, if appropriate?

Copy link
Contributor

@aryairani aryairani Jan 21, 2026

Choose a reason for hiding this comment

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

We are trying to move to ghc 9.10 in order to update other parts of the toolchain, but trying to make sure we don't lose some important optimization without realizing it. Here's benchmark outputs Greg found in their tentative ghc 9.10 update branch.

#6046 (comment)

```

``` ucm
> run suite

()
```
17 changes: 0 additions & 17 deletions unison-src/transcripts-manual/benchmarks/array-sort.u

This file was deleted.

6 changes: 0 additions & 6 deletions unison-src/transcripts-manual/benchmarks/each.u

This file was deleted.

10 changes: 0 additions & 10 deletions unison-src/transcripts-manual/benchmarks/fibonacci.u

This file was deleted.

3 changes: 0 additions & 3 deletions unison-src/transcripts-manual/benchmarks/listfilter.u

This file was deleted.

3 changes: 0 additions & 3 deletions unison-src/transcripts-manual/benchmarks/listmap.u

This file was deleted.

13 changes: 0 additions & 13 deletions unison-src/transcripts-manual/benchmarks/map.u

This file was deleted.

13 changes: 0 additions & 13 deletions unison-src/transcripts-manual/benchmarks/natmap.u

This file was deleted.

26 changes: 0 additions & 26 deletions unison-src/transcripts-manual/benchmarks/output.bench.txt

This file was deleted.

8 changes: 0 additions & 8 deletions unison-src/transcripts-manual/benchmarks/random.u

This file was deleted.

8 changes: 0 additions & 8 deletions unison-src/transcripts-manual/benchmarks/simpleloop.u

This file was deleted.

13 changes: 0 additions & 13 deletions unison-src/transcripts-manual/benchmarks/stm.u

This file was deleted.

Loading
Loading