Skip to content

Set up benchmarks to run nightly on cron (add lf-bench, slurm + cron wrappers, testing) - #8

Merged
olivialynn merged 28 commits into
mainfrom
adopt-lbench-fixtures
Oct 16, 2026
Merged

olivialynn merged 28 commits into
mainfrom
adopt-lbench-fixtures

Conversation

@olivialynn

@olivialynn olivialynn commented Oct 5, 2026 •

Copy link
Copy Markdown
Member

Brief overview:
Adds lf-bench as a dependency to wrap and manage runs of the benchmarks written in astronomy-commons/ppdb_hats#7. Also, cron and slurm wrappers for launching from SDF crontab.

For a more detailed explanation of the nightly benchmarks, I recommend reading the README added to the benchmarks/ directory.

Once this PR is merged, I will launch the cron job (#9) and nightly results will be saved to /sdf/data/rubin/shared/lsdb_commissioning/rubin_alert_archive_benchmarks (I explicitly made this dir read/editable to rubin_users group).

Main changes:

  • Used the lbench_dask fixture to wrap the query (mostly the final compute) in each of the benchmark tests
  • Added benchmarks/nightly/run.sbatch, Slurm job to run benchmarks
  • Added benchmarks/nightly/submit.sh, to set up the venv and launch the Slurm job

Also:

  • Moved some more central test stuff to the benchmark conftest
  • Added an lbench override in the conftest, specifically to let us use benchmark.pedantic to ask for 1 warm-up and 5 timed rounds (then skip a follow-up cprofile run)
  • In one of the tests, replaced df.query(f"diaObjectId in {sample_ids.tolist()}") with df[df["diaObjectId"].isin(sample_ids)] for faster querying (recommended by our friend 🙇 )

Note:

- Wrap each benchmark's compute in lbench_dask so --lbench records timings,
  cProfile output, and Dask performance reports.
- Move the catalog and Dask-client fixtures into conftest; add an
  ALERT_ARCHIVE_CATALOG_DIR env override (defaulting to the HPC path) and a
  2-worker single_thread_dask_client override (ALERT_ARCHIVE_DASK_WORKERS)
  that reproduces the original LocalCluster.
- Add a [benchmark] optional-dependencies group (lf-bench from git, lsdb,
  nested-pandas, hats, astropy).
- Shim an lf-bench / pytest-benchmark>=5 incompatibility (lf-bench passes an
  open file handle where pytest-benchmark expects a path) so results JSON is
  written. Remove once lf-bench is fixed upstream.

The benchmark logic (including the naive light-curve aggregation) is unchanged.
…ncies

- Move lsdb, nested-pandas, and hats from the [benchmark] extra to the main
  project dependencies (astropy and lf-bench stay benchmark-only).
- Use the original multi-statement style in the benchmark bodies; each test only
  swaps the client fixture for lbench_dask and wraps the compute call.
@olivialynn
olivialynn force-pushed the adopt-lbench-fixtures branch from e721667 to def6620 Compare October 9, 2026 15:38
@codecov

codecov Bot commented Oct 12, 2026

Copy link
Copy Markdown

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

@olivialynn olivialynn changed the title Adopt lf-bench fixtures for the alert archive benchmarks Set up benchmarks to run nightly on cron (add lf-bench, slurm + cron wrappers, testing) Oct 14, 2026

@camposandro camposandro left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks, this is a lot of work!!

Left some comments/questions below, most of them are minor:

Comment thread .github/workflows/nightly-benchmark-checks.yml
Comment thread .github/workflows/publish-to-pypi.yml Outdated
Comment thread benchmarks/nightly/requirements.txt
Comment thread benchmarks/nightly/run.sbatch
Comment thread benchmarks/nightly/run.sbatch
Comment thread benchmarks/conftest.py

@pytest.fixture
def lbench(benchmark_results_dir, benchmark, request):
"""Override lf-bench's ``lbench`` fixture to fix the run count and allow skipping cProfile.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

As a follow-up to this PR, would it be worth filing an issue in lsdb-benchmarking to make the lbench fixture more flexible? It'd be nice if we could do some of these overrides with a decorator. I think the %%lbench notebook magic already takes --rounds, so I'm assuming there's already something in place to make it possible.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

#11

Comment thread pyproject.toml
# Benchmarking harness (pytest plugin + dashboard). Keep the commit in sync
# with benchmarks/nightly/requirements.txt.
"lf-bench @ git+https://github.com/lincc-frameworks/lsdb-benchmarking@605bd6fedfdc592e7ff3249bf06db0715f13587e",
"astropy",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Since astropy is already included in hats and we're not forcing any other pin here, do we need it?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The powers that be have told me that, since we do import it directly in the benchmarks, we should include it in the deps - but a good idea to avoid pinning it for sure

Comment thread benchmarks/nightly/submit.sh Outdated

@camposandro camposandro left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Looks good!

@olivialynn
olivialynn merged commit 50dfb0e into main Oct 16, 2026
7 checks passed
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