Skip to content
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
84 changes: 84 additions & 0 deletions .github/elide/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,20 @@ meso benchmarks and benchmarks of real packages on a native standalone and repor
and on pull requests that carry the label `perf:bench`. `codspeed-bench` is the driver that runs
the benchmarks and writes the results.

The suites of `codspeed-bench` that the workflow runs:

| Suite | What it measures | Files |
|---|---|---|
| `micro-native` | C API micro benchmarks, warmed up | upstream's `micro`, table in `mx_graalpython_bench_param.py` |
| `meso` | pure Python benchmarks, warmed up | upstream's `meso`, table in `mx_graalpython_bench_param.py` |
| `packages` | real packages, warmed up (see "Package benchmarks") | the fork's `packages` |
| `interp` | some `meso` benchmarks without the JIT compiler (see "Interpreter, start-up and memory") | the fork's `interp` table, upstream's `meso` files |
| `startup` | fresh processes: start-up, imports, a first run | the fork's `startup` |
| `memory` | peak RSS (and wall time) of fresh processes holding data | the fork's `memory` |

CodSpeed compares the fastest iteration of each row with the base branch. The workflow also writes
the peak RSS of every benchmark to the run's summary page (`walltime-summary.md`).

The standalone and the packages' wheels are built on the pool. The measurement runs on the
benchmark runner with the label `linux-amd64-bench`, which is shared between repositories, so only
the measurement runs there.
Expand All @@ -65,6 +79,8 @@ merges from upstream cannot conflict with it:
| `pydantic-json` | `validate_json` and `dump_json` of a list of nested models with a discriminated union, and `model_dump_json`/`model_validate_json` per model |
| `pydantic-models` | `model_validate` from dicts and `model_dump`, `model_validate_json` and `model_dump_json`, of nested models with a field validator |
| `orjson-roundtrip` | `dumps` and `loads` of a nested document, also indented with sorted keys, and `dumps` of dataclasses |
| `orjson-loads` | the `loads` of `orjson-roundtrip`, on the same document |
| `orjson-dumps` | the `dumps` of `orjson-roundtrip`, on the same document: compact, indented with sorted keys, and dataclasses |
| `pandas-csv` | `read_csv` of an in-memory CSV (dates, a categorical column), a filter, `to_csv`, a groupby |
| `pandas-str` | `Series.str` methods (strip, lower, contains, extract, split, replace, title) and `to_datetime` |
| `pandas-groupby-merge` | merges of a fact table with two dimension tables, groupby aggregations, `pivot_table`, a grouped rank |
Expand Down Expand Up @@ -138,6 +154,74 @@ a network (`package-venv`) and runs every package benchmark for four iterations;
virtual environment in the job's temporary directory and runs the suite with that environment's
interpreter (`--suite-python`).

### Interpreter, start-up and memory

Three more suites of `codspeed-bench`, each with a `benchmarks.txt` in its own folder next to
`packages`; like the package benchmarks, their files carry no copyright header. Their sizes are estimates for the benchmark host; a resize is a change of one line in
`benchmarks.txt` and starts a new history on CodSpeed, because the size is part of the name.

`interp` runs some of upstream's `meso` benchmarks (richards3, bm-float, nbody3, raytrace-simple,
fannkuchredux3, fasta3) with Truffle compilation switched off, `--experimental-options
--engine.Compilation=false`: the speed of code that is not compiled, which is what most code runs at
before the compiler gets to it. Its table names the files in `meso` and gives sizes much smaller than
those of `meso`, for iterations of about 0.2 to 1 s. The options belong to the suite: the driver
gives them to every benchmark of it, also when reporting to CodSpeed, where `--python-arg` is
refused. The rows are `interp/<name>[<size>]`, next to `meso/<name>[<size>]`.

`startup` is in the harness format, but one iteration starts fresh processes of the interpreter
(`sys.executable`, with the interpreter options of the harness process, from `sys.orig_argv`), one
after the other, and waits for each; the workload argument is the number of processes, so that an
iteration takes at least about 0.3 s:

| Benchmark | What each process does |
|---|---|
| `pass` | `-c pass` |
| `stdlib-imports` | imports json, re, decimal, datetime, collections, pathlib, argparse, logging, subprocess, typing, dataclasses and asyncio (`memory/stdlib-imports.py`) |
| `first-run` | a small pure Python workload, once (`startup/first-run.py` as a script), and checks its result |

`memory` is not in the harness format. Its benchmarks are scripts: every iteration runs one in a
fresh process, `<interpreter> <name>.py <size>`, and the driver takes the wall time of the whole
process and its peak RSS (`ru_maxrss` from `wait4`). The scripts mirror upstream's `heap` benchmarks,
which sleep 3 s per process for upstream's memory sampling, without the sleep:

| Benchmark | What the process holds when it exits |
|---|---|
| `idle` | nothing; the interpreter after start-up (`heap/post-startup.py`) |
| `stdlib-imports` | the modules of `startup/stdlib-imports` |
| `objects` | a list of 1,000,000 instances of a class with two attributes (`heap/allocate-objects.py`) |
| `dicts` | a list of 1,000,000 dicts with two string keys |
| `strings` | a list of 1,000,000 distinct strings of up to 7 characters |

The peak RSS includes everything the process allocated on the way, garbage included, and depends on
GraalPy's heap sizing; that is what a user of the interpreter pays for.

#### Peak RSS on CodSpeed

CodSpeed takes only times, so every benchmark of `memory` gives two rows there:

- `memory/<name>[<size>]`, the wall time of one process, from the start of the interpreter to its
exit, and
- `memory/<name>[<size>][peak-rss: 1 ms = 1 MiB]`, whose "time" is the peak RSS of one process:
1 ms on CodSpeed is 1 MiB, so 300 ms is 300 MiB. The value is the median over the processes of the
second half of the iterations (the ones whose durations are the samples of the first row), the
same in every round, so its spread is zero and "faster" means "smaller".

Both are in the same result file. `walltime-summary.json` keeps the peak RSS rows apart from the
times, under `memory`, each with `"kind": "memory"`, the unit (KiB), the row it belongs to (`of`) and
the peak RSS of every process; `measured` keeps the times as before, with `rss_kb_per_process` and
`peak_rss_kb` added for the benchmarks of `memory`.

`walltime-summary.md`, written next to it and appended to the run's summary page, lists the peak RSS
of every benchmark of every suite. For a harness benchmark it is that of the whole harness process
over all iterations, including the compiler's memory; for `startup` on Linux it is the larger of the
harness process and the processes it started (`wait4` counts the children a process waited for);
for `memory` it is the value of the peak RSS row.

To compare with CPython on the same machine, `--no-suite-options` leaves out the options of
`interp` (the rows then measure CPython's interpreter on the same sizes), for example
`python3 .github/elide/codspeed-bench --python python3 --no-suite-options --label cpython --suite interp startup memory --output <dir>`.
It is refused when reporting to CodSpeed.

### Diagnosing noisy rows

A manual run of `elide-codspeed.yml` with the input `diagnose` set measures without reporting to
Expand Down
Loading
Loading