Skip to content

Add reservation benchmark#151

Open
jerbaroo wants to merge 1 commit into
masterfrom
jerbaroo-benchmark
Open

Add reservation benchmark#151
jerbaroo wants to merge 1 commit into
masterfrom
jerbaroo-benchmark

Conversation

@jerbaroo

@jerbaroo jerbaroo commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

This PR adds a benchmark which can be run with just bench-chunks-select. It produces the SVG contained in this PR. Output from the Rust bench is written to a CSV (not committed) which is then read by Python to produce a graph. The Rust bench also prints the information to stdout, which looks like:

just bench-chunks-select
   Compiling opsqueue v0.36.0 (/home/jeremy-barisch-rooney/channable/opsqueue/opsqueue)
    Finished `bench` profile [optimized] target(s) in 17.32s
     Running benches/chunks_select.rs (target/release/deps/chunks_select-d5aca04d748d2c69)
SHAPE                          STRATEGY                            SIZE         MEDIAN     P10 / P90
---------------------------------------------------------------------------------------------------------
    Companies: 10
    Submissions per company: 1
    Chunks per submission: 10
FewSubmissionsManyChunks       Random                              100          55.1       50.5 / 60.6
FewSubmissionsManyChunks       PreferDistinct(company_id, Oldest)  100          107.3      99.0 / 117.5
    Companies: 10
    Submissions per company: 1
    Chunks per submission: 50
FewSubmissionsManyChunks       Random                              500          52.4       48.9 / 69.4
FewSubmissionsManyChunks       PreferDistinct(company_id, Oldest)  500          253.0      184.0 / 272.5
    Companies: 10
    Submissions per company: 1
    Chunks per submission: 100
FewSubmissionsManyChunks       Random                              1000         53.2       49.3 / 59.1
FewSubmissionsManyChunks       PreferDistinct(company_id, Oldest)  1000         281.0      246.5 / 377.9
    Companies: 10
    Submissions per company: 1
    Chunks per submission: 200
FewSubmissionsManyChunks       Random                              2000         54.5       49.2 / 62.3
FewSubmissionsManyChunks       PreferDistinct(company_id, Oldest)  2000         480.2      424.4 / 721.8
    Companies: 10
    Submissions per company: 1
    Chunks per submission: 400
FewSubmissionsManyChunks       Random                              4000         56.1       53.5 / 62.9
FewSubmissionsManyChunks       PreferDistinct(company_id, Oldest)  4000         1100.2     799.4 / 1247.0

@jerbaroo
jerbaroo force-pushed the jerbaroo-benchmark branch from 7592f8f to da93859 Compare July 23, 2026 20:16

@ReinierMaas ReinierMaas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I didn't review opsqueue/benches/chunks_select.rs yet, only the top block comment. But I think I already have some good advice that can be helpful.

Comment thread justfile
source "./.setup_local_venv.sh"

timeout {{pytest_timeout_seconds}} pytest --color=yes {{TEST_ARGS}}
pytest --timeout {{pytest_timeout_seconds}} --color=yes {{TEST_ARGS}}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think this covers what the previous timeout covered. The previous timeout covers the problem that the GIL isn't ever released by the OpsQueue code. This also only mentions that it is the timeout before dumping the stacks, does it also exit pytest at that point?

XRef: #154 for dumping the transitive xdist-worker stacks via signal handlers on top over killing the process on hanging on the GIL lock.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We also have in python per test timeouts defined in pyproject.toml if that didn''t trigger it is probably a lock-up:

# Individual tests should be very fast. They should never take multiple seconds
# If after 120sec (accomodating for a toaster-like PC, or an overloaded Semaphore runner)
# there is no progress, assume a deadlock
timeout=20

Comment thread default.nix
pythonEnv
];
# Fixes: libstdc++.so.6: cannot open shared object file: No such file or directory
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [ pkgs.stdenv.cc.cc.lib ];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Which dependency needed this? And at what time of it lifecycle build or runtime?

Just enabling the benchmarks probably caused it to show-up for you to add it here. What I am thinking is should we also ensure that our packaged opsqueue server has this library path available.

Comment on lines +2 to +7
"""Plot the chunks_select benchmark: one subplot per backlog shape, a line per strategy.

Reads target/chunks_select_bench.csv (written by the bench) and writes a PNG next to
this script so it can be committed alongside the code it measures.

"""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The committed file is a SVG. Not a problem but a documentation mismatch.

Comment on lines +1 to +19
/// FOR EACH shape:
/// FOR EACH amount of chunks:
/// FOR EACH strategy:
///
/// // Setup
/// Create fresh temporary SQLite database
/// Insert chunks
///
/// // MEASURE
/// FOR _ in (SAMPLES + WARMUP):
/// Start Timer
/// Execute SQL Query -> Fetch EXACTLY ONE chunk
/// Stop Timer
/// IF (not warmup): save duration
///
/// // REPORT & CLEANUP
/// Calculate stats
/// Write result to terminal and CSV
/// Delete temporary database files

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If you flip FOR EACH amount of chunks and FOR EACH strategy you can extend chunks/submissions instead of generating an entirely new dataset for each measurement. This can greatly speed-up your test runs.

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