Skip to content

Commit d2e2f86

Browse files
authored
Refactor/benchmarks (#65)
* Refactors benchmarks for CI performance suite Consolidates and optimizes benchmarks into a CI performance suite for faster and more comprehensive regression detection. - Replaces `small_scale_triangulation.rs` with `ci_performance_suite.rs` - Adds 5D triangulation benchmarks - Modifies benchmark jobs to use the CI performance suite - Removes allocation counting from `ci_performance_suite` benchmarks - Adds new benchmarks for memory scaling and triangulation vs hull memory usage * Refactors and expands benchmark suite Significantly expands and refactors the benchmark suite to include comprehensive performance measurements across dimensions 2D-5D. Introduces microbenchmarks for core algorithms like Bowyer-Watson triangulation, neighbor assignment, and duplicate cell removal. Adds memory usage and validation benchmarks to assess allocation patterns and correctness. Updates point generation to be more consistent and reproducible using a util module. Provides targeted benchmarks for incremental construction, measuring vertex addition performance. These enhancements provide deeper insights into performance bottlenecks and scaling behavior across different dimensions. * Refactors and expands benchmark suite Improves the benchmark suite by refactoring random point generation, enhancing CI performance benchmarks, and adding memory analysis capabilities. This change standardizes point generation using a central utility function, improving consistency and maintainability. * Refactors baseline generation workflow Streamlines the baseline generation workflow by relocating the baseline results file to the artifact directory directly within the generation script. This change simplifies artifact preparation and cleanup, ensuring consistency and reducing redundancy in file handling. Additionally, updates Ruff configuration and usage across the project for improved code quality and formatting. * Improves changelog title formatting with edge cases Adds tests to cover edge cases in changelog title formatting, specifically focusing on line wrapping with very short length limits. It also fixes a bench command to include the workspace. These tests ensure the commit link is split correctly across multiple lines and bolding is omitted when the line length is insufficient. * Improves test reliability and documentation Updates a test to mock JSON loading more effectively, preventing potential issues with file access during testing. Refines documentation in WARP.md to improve clarity and consistency, including: - Updates clippy command with more pedantic lints - Clarifies cspell usage and terminology - Removes redundant documentation validation step - Clarifies run_all_examples.sh execution - Adds more specialized tests These changes enhance code quality, testability, and documentation accuracy, promoting better development practices. * Improves CI performance and changelog utils Enhances CI workflow by recommending branch strategies to avoid unnecessary performance testing. Refines changelog title formatting to handle long titles and ensure proper markdown escaping. Updates WARP guidance to clarify the use of automated tools and code validation procedures.
1 parent f10aba3 commit d2e2f86

31 files changed

+2951
-831
lines changed

.github/workflows/benchmarks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ jobs:
346346
echo " Baseline origin: ${BASELINE_ORIGIN:-unknown}"
347347
348348
# This will exit with code 1 if significant regressions are found
349-
echo " Using full comparison mode against ${BASELINE_ORIGIN:-unknown} baseline"
349+
echo " Using CI performance suite against ${BASELINE_ORIGIN:-unknown} baseline"
350350
BASELINE_PATH="baseline-artifact/baseline_results.txt"
351351
if uv run benchmark-utils --help >/dev/null 2>&1; then
352352
uv run benchmark-utils compare --baseline "$BASELINE_PATH"

.github/workflows/generate-baseline.yml

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,12 @@ jobs:
7777
run: |
7878
echo "🚀 Generating performance baseline for tag $TAG_NAME"
7979
80-
# Run baseline generation using Python CLI tool
80+
# Run baseline generation using Python CLI tool with CI performance suite
8181
uv run benchmark-utils generate-baseline \
8282
|| uv run python -m scripts.benchmark_utils generate-baseline
8383
8484
# Verify baseline was created
85-
if [ ! -f "benches/baseline_results.txt" ]; then
85+
if [ ! -f "baseline-artifact/baseline_results.txt" ]; then
8686
echo "❌ Baseline generation failed - no baseline file created"
8787
exit 1
8888
fi
@@ -91,9 +91,9 @@ jobs:
9191
9292
# Show baseline summary
9393
echo "📊 Baseline summary:"
94-
head -n 10 benches/baseline_results.txt
94+
head -n 10 baseline-artifact/baseline_results.txt
9595
echo "..."
96-
benchmark_count=$(grep -c "^===" benches/baseline_results.txt || echo "0")
96+
benchmark_count=$(grep -c "^===" baseline-artifact/baseline_results.txt || echo "0")
9797
echo "Total benchmarks: $benchmark_count"
9898
9999
- name: Prepare baseline artifact
@@ -102,14 +102,9 @@ jobs:
102102
SAFE_COMMIT_SHA: ${{ github.sha }}
103103
SAFE_RUN_ID: ${{ github.run_id }}
104104
run: |
105-
# Create artifact directory
106-
mkdir -p baseline-artifact
107-
108-
# Copy baseline file with tag-specific name
109-
cp benches/baseline_results.txt "baseline-artifact/baseline-$TAG_NAME.txt"
110-
111-
# Also copy as generic name for easy download
112-
cp benches/baseline_results.txt "baseline-artifact/baseline_results.txt"
105+
# The baseline file is already in baseline-artifact/ from the script
106+
# Just copy it with tag-specific name
107+
cp baseline-artifact/baseline_results.txt "baseline-artifact/baseline-$TAG_NAME.txt"
113108
114109
# Create metadata file
115110
cat > "baseline-artifact/metadata.json" <<EOF
@@ -148,7 +143,7 @@ jobs:
148143
if: ${{ success() }}
149144
run: |
150145
# Remove temporary baseline file from working directory
151-
rm -f benches/baseline_results.txt
146+
rm -f baseline-artifact/baseline_results.txt
152147
echo "✅ Cleaned up temporary baseline file"
153148
154149
- name: Display next steps

CHANGELOG.md

Lines changed: 134 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,122 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
99

1010
## [Unreleased](https://github.com/acgetchell/delaunay/compare/v0.4.1...HEAD)
1111

12+
### Merged Pull Requests
13+
14+
- Docs/release v0.4.2 [`#60`](https://github.com/acgetchell/delaunay/pull/60)
15+
- Test/benchmarking [`#59`](https://github.com/acgetchell/delaunay/pull/59)
16+
- Fix/squashed commit body parsing [`#58`](https://github.com/acgetchell/delaunay/pull/58)
17+
1218
### Changed
1319

14-
- **Enhances changelog generation and release process** [`3a57f53`](https://github.com/acgetchell/delaunay/commit/3a57f53b62a9888bf55d7cc021d9d00865b671ca)
20+
- **Documentation updates for upcoming v0.4.2** [`f10aba3`](https://github.com/acgetchell/delaunay/commit/f10aba3)
21+
22+
Updates README to the `scripts/` directory detailing the purpose, usage, and dependencies of each utility script.
23+
24+
Updates WARP.md to focus on AI guidance
25+
26+
Also adds minor spell check fixes.
27+
28+
- **Refactors examples and enhances testing structure** [`f10aba3`](https://github.com/acgetchell/delaunay/commit/f10aba3)
29+
30+
Refactors the example directory and enhances the testing framework to improve code organization and maintainability.
31+
32+
- **Moves the \`test\_alloc\_api.rs\` and \`test\_circumsphere.rs\` examples to the \`tests/\` directory and renames them to \`allocation\_api.rs\` and**
33+
34+
**\`circumsphere\_debug\_tools.rs\`, respectively, to reflect their role as debugging and testing utilities.**
35+
[`f10aba3`](https://github.com/acgetchell/delaunay/commit/f10aba3)
36+
37+
- **Updates documentation to reflect these changes.** [`f10aba3`](https://github.com/acgetchell/delaunay/commit/f10aba3)
38+
39+
- **Refactors examples and updates documentation** [`f10aba3`](https://github.com/acgetchell/delaunay/commit/f10aba3)
40+
41+
Renames `implicit_conversion.rs` to `into_from_conversions.rs` and updates its content to better reflect the use of `Into`/`From` traits for coordinate
42+
conversions.
43+
44+
This change improves clarity and modernizes the example to align with current Rust best practices. Also updates documentation across multiple files to reflect
45+
the rename and new example.
46+
47+
- **Improves benchmark comparisons and tooling** [`f10aba3`](https://github.com/acgetchell/delaunay/commit/f10aba3)
48+
49+
Refactors the benchmark comparison process to use the baseline artifact directly instead of copying it to a temporary location.
50+
51+
This change avoids unnecessary file operations and simplifies the workflow.
52+
It also introduces average regression calculation for more accurate performance analysis, taking individual benchmark variations into account.
53+
Adds new pytest-based tests for the benchmark comparison tool to improve reliability.
54+
55+
Cleans up temporary baseline files after artifact generation to prevent clutter and potential conflicts.
56+
Updates the WARP.md documentation to reflect recent changes and adds guidance on shell script formatting.
57+
Also updates the all examples script to improve error handling and example discovery.
58+
59+
- **Changes benchmarks to use geometric mean** [`f10aba3`](https://github.com/acgetchell/delaunay/commit/f10aba3)
60+
61+
Enhances benchmark reporting with geometric mean for time changes and commit SHA resolution from metadata.
62+
63+
Adds Clippy configuration and improves Rust code quality checks.
64+
65+
Refactors example running to improve discovery and handling of Cargo examples, including timeout support.
66+
67+
Updates WARP.md with more detailed instructions on code quality and style conventions, including formatting, linting, spell checking, and JSON validation.
68+
69+
- **Improves benchmark comparison and example handling** [`f10aba3`](https://github.com/acgetchell/delaunay/commit/f10aba3)
70+
71+
Enhances benchmark comparison by normalizing time units, using geometric mean for averaging changes, and guarding against non-positive ratios.
72+
73+
Adds robustness to example script by checking for example directory and adding timeout and kill signals.
74+
75+
Also includes minor fixes to metadata handling and test assertions.
76+
77+
- **Modifies benchmark workflows to correctly identify baseline results files and set environment variables accordingly.**
78+
79+
[`f10aba3`](https://github.com/acgetchell/delaunay/commit/f10aba3)
1580

16-
- **Automates performance regression testing** [`d57a6fd`](https://github.com/acgetchell/delaunay/commit/d57a6fd6aee01ec5c65940d8177896bcb191e06b)
81+
- **Enhances example execution script to handle timeouts with or without \`timeout\` command, ensuring consistent behavior across environments.**
82+
83+
[`f10aba3`](https://github.com/acgetchell/delaunay/commit/f10aba3)
84+
85+
- **Updates shell script formatting guidelines in WARP.md to enforce tab indentation.** [`f10aba3`](https://github.com/acgetchell/delaunay/commit/f10aba3)
86+
87+
- **Updates example script and documentation** [`f10aba3`](https://github.com/acgetchell/delaunay/commit/f10aba3)
88+
89+
Updates the example script to support time units in `EXAMPLE_TIMEOUT`.
90+
91+
Removes the unnecessary creation of the results directory in the example script.
92+
93+
Clarifies shell script formatting requirements in the documentation.
94+
95+
Adds tracking issues for future improvements.
96+
97+
Fixes #61
98+
99+
- **Refactors benchmarks for CI performance suite** [`4863dfe`](https://github.com/acgetchell/delaunay/commit/4863dfe9ae9fabef838da214e5eb35f4c74b7d12)
100+
101+
- **Refactors and expands benchmark suite** [`43e55a9`](https://github.com/acgetchell/delaunay/commit/43e55a9e90239de0ee030d5de38fc8fdfec17c51)
102+
103+
- **Refactors and expands benchmark suite** [`f77e441`](https://github.com/acgetchell/delaunay/commit/f77e441ec19f4184983eca21f85bbca6ce554932)
104+
105+
### Removed
106+
107+
- **Removes outdated examples and clarifies the purpose of remaining examples in the README.**
108+
109+
[`f10aba3`](https://github.com/acgetchell/delaunay/commit/f10aba3)
110+
111+
### Fixed
112+
113+
- **Fixes benchmark and regression reports,** [`f10aba3`](https://github.com/acgetchell/delaunay/commit/f10aba3)
114+
115+
Refactors benchmark scripts to improve baseline commit SHA resolution and report top regressions.
116+
117+
Adds timeout functionality to example scripts, including support for `gtimeout` on macOS, and introduces an `EXAMPLE_TIMEOUT` environment variable.
118+
119+
Updates tests and documentation accordingly.
120+
121+
- **Fixes benchmark and example scripts** [`f10aba3`](https://github.com/acgetchell/delaunay/commit/f10aba3)
122+
123+
Refactors benchmark artifact handling and example execution for better reliability and clarity.
124+
125+
- **Corrects an issue in circumsphere tests, boundary detections.** [`f10aba3`](https://github.com/acgetchell/delaunay/commit/f10aba3)
126+
127+
- **Fix pesky shell script linting** [`f10aba3`](https://github.com/acgetchell/delaunay/commit/f10aba3)
17128

18129
## [v0.4.1](https://github.com/acgetchell/delaunay/compare/v0.4.0...v0.4.1) - 2025-08-30
19130

@@ -50,15 +161,15 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
50161

51162
Also includes minor improvements to benchmark comparison and documentation.
52163

53-
- **Pins `tarpaulin` version in code coverage workflow and adds a cache restore key for
164+
- **Pins \`tarpaulin\` version in code coverage workflow and adds a cache restore key for improved caching.**
54165

55-
improved caching.** [`5fb31b1`](https://github.com/acgetchell/delaunay/commit/5fb31b1)
166+
[`5fb31b1`](https://github.com/acgetchell/delaunay/commit/5fb31b1)
56167

57-
- **Adds common directories to `.cspell.json` to prevent spellcheck errors in those
168+
- **Adds common directories to \`.cspell.json\` to prevent spellcheck errors in those directories.**
58169

59-
directories.** [`5fb31b1`](https://github.com/acgetchell/delaunay/commit/5fb31b1)
170+
[`5fb31b1`](https://github.com/acgetchell/delaunay/commit/5fb31b1)
60171

61-
- **Enhances the `tag-from-changelog.sh` script to support hyperlink changelog syntax.** [`5fb31b1`](https://github.com/acgetchell/delaunay/commit/5fb31b1)
172+
- **Enhances the \`tag-from-changelog.sh\` script to support hyperlink changelog syntax.** [`5fb31b1`](https://github.com/acgetchell/delaunay/commit/5fb31b1)
62173

63174
- **Adds DOI badge to README** [`a5f0f51`](https://github.com/acgetchell/delaunay/commit/a5f0f51dae0174cdf541f7e556e13441caa2a850)
64175

@@ -142,10 +253,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
142253

143254
Addresses several issues and introduces enhancements across benchmark infrastructure and related scripts, resulting in improved robustness and functionality.
144255

145-
- **Updates `generate_baseline.sh` to collect git commit info even when git isn't available
146-
147-
and fixes an issue that prevented benchmarks from running in dev mode.** [`5fb31b1`](https://github.com/acgetchell/delaunay/commit/5fb31b1)
148-
149256
- **Updates WARP.md to find and execute shellcheck and shfmt.** [`5fb31b1`](https://github.com/acgetchell/delaunay/commit/5fb31b1)
150257

151258
- **Improves benchmark and CI scripts** [`5fb31b1`](https://github.com/acgetchell/delaunay/commit/5fb31b1)
@@ -171,13 +278,18 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
171278

172279
- **Corrects environment variable assignment in benchmark workflows for proper behavior.** [`5fb31b1`](https://github.com/acgetchell/delaunay/commit/5fb31b1)
173280

174-
- **Improves the error handling, unit handling, and overall stability of benchmark parsing
281+
- **Improves the error handling, unit handling, and overall stability of benchmark parsing scripts.**
282+
283+
[`5fb31b1`](https://github.com/acgetchell/delaunay/commit/5fb31b1)
284+
285+
- **Updates \`generate\_baseline.sh\` to collect git commit info even when git isn't available and fixes an issue that prevented benchmarks from running in**
175286

176-
scripts.** [`5fb31b1`](https://github.com/acgetchell/delaunay/commit/5fb31b1)
287+
**dev mode.**
288+
[`5fb31b1`](https://github.com/acgetchell/delaunay/commit/5fb31b1)
177289

178-
- **Improves hardware comparison logic to reduce false positives and uses PowerShell for
290+
- **Improves hardware comparison logic to reduce false positives and uses PowerShell for hardware detection on Windows.**
179291

180-
hardware detection on Windows.** [`5fb31b1`](https://github.com/acgetchell/delaunay/commit/5fb31b1)
292+
[`5fb31b1`](https://github.com/acgetchell/delaunay/commit/5fb31b1)
181293

182294
## [v0.4.0](https://github.com/acgetchell/delaunay/compare/v0.3.5...v0.4.0) - 2025-08-22
183295

@@ -218,13 +330,13 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
218330

219331
correctness and performance of the new functionality.
220332

221-
- **Implements a pure incremental Delaunay triangulation algorithm, removing the supercell
333+
- **Implements a pure incremental Delaunay triangulation algorithm, removing the supercell approach and improving performance scaling.**
222334

223-
approach and improving performance scaling.** [`2e31533`](https://github.com/acgetchell/delaunay/commit/2e31533)
335+
[`2e31533`](https://github.com/acgetchell/delaunay/commit/2e31533)
224336

225-
- **Adds reusable buffers to the Bowyer-Watson algorithm, reducing memory allocation
337+
- **Adds reusable buffers to the Bowyer-Watson algorithm, reducing memory allocation overhead.**
226338

227-
overhead.** [`2e31533`](https://github.com/acgetchell/delaunay/commit/2e31533)
339+
[`2e31533`](https://github.com/acgetchell/delaunay/commit/2e31533)
228340

229341
- **Introduces robust geometric predicates to handle degenerate cases more effectively.** [`2e31533`](https://github.com/acgetchell/delaunay/commit/2e31533)
230342

@@ -295,9 +407,9 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
295407

296408
This commit introduces several key changes:
297409

298-
- **Optimizes validation methods with early termination and pre-computed mappings, leading
410+
- **Optimizes validation methods with early termination and pre-computed mappings, leading to faster validation.**
299411

300-
to faster validation.** [`2e31533`](https://github.com/acgetchell/delaunay/commit/2e31533)
412+
[`2e31533`](https://github.com/acgetchell/delaunay/commit/2e31533)
301413

302414
- **Uses arc-swap crate for lock-free atomic cache updates.** [`2e31533`](https://github.com/acgetchell/delaunay/commit/2e31533)
303415

@@ -360,7 +472,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
360472

361473
This change addresses potential issues with floating-point precision and error handling, leading to more robust and reliable Delaunay triangulations.
362474

363-
Also includes formatting and linter fixes, and updates CI workflow to include rustfmt and clippy checks to maintain code quality and consistency. Adds
475+
Also includes formatting and linter fixes, and updates CI workflow to include rustfmt and clippy checks to maintain code quality and consistency. Adds
364476
perturbation test and enhances failure handling in degenerate cases.
365477

366478
- **Improves numerical stability and robustness** [`2e31533`](https://github.com/acgetchell/delaunay/commit/2e31533)

CONTRIBUTING.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ to experienced developers looking to contribute significant features.
1111
- [Development Environment Setup](#development-environment-setup)
1212
- [Project Structure](#project-structure)
1313
- [Development Workflow](#development-workflow)
14+
- [CI Performance Testing](#ci-performance-testing)
1415
- [Code Style and Standards](#code-style-and-standards)
1516
- [Testing](#testing)
1617
- [Documentation](#documentation)
@@ -229,6 +230,55 @@ The project follows a standard Rust library structure with additional tooling fo
229230

230231
For detailed code organization patterns and module structure, see [code organization documentation][code-organization].
231232

233+
## CI Performance Testing
234+
235+
### ⚠️ **Important: Rust Code Changes Trigger Lengthy Baseline Comparisons**
236+
237+
**Any changes to Rust code will automatically trigger performance regression testing in CI, which can take 30-45 minutes to complete.**
238+
239+
The benchmark workflow runs on changes to:
240+
241+
- `src/**` - Any core library code
242+
- `benches/**` - Benchmark code
243+
- `Cargo.toml` or `Cargo.lock` - Dependencies
244+
245+
### **Branch Strategy Recommendation**
246+
247+
To avoid triggering lengthy baseline comparisons unnecessarily:
248+
249+
**Recommended**: Keep documentation and Python utility updates in **separate branches/PRs** from Rust code changes
250+
251+
**Avoid**: Mixing documentation updates with Rust code changes in the same commit/PR
252+
253+
### **Examples**
254+
255+
**Good workflow:**
256+
257+
```bash
258+
# Branch 1: Documentation updates only
259+
git checkout -b docs/update-readme
260+
# Edit README.md, CONTRIBUTING.md, etc.
261+
git commit -m "docs: update contributing guidelines"
262+
# → No benchmarks triggered, fast CI
263+
264+
# Branch 2: Rust code changes (separate PR)
265+
git checkout -b feat/improve-algorithm
266+
# Edit src/core/triangulation.rs
267+
git commit -m "feat: optimize triangulation algorithm"
268+
# → Benchmarks triggered, but isolated to code changes
269+
```
270+
271+
**Avoid:**
272+
273+
```bash
274+
# Mixed changes (triggers benchmarks for trivial doc fixes)
275+
git add README.md src/core/triangulation.rs
276+
git commit -m "feat: algorithm improvement + doc updates"
277+
# → 45-minute benchmark run for a simple doc fix
278+
```
279+
280+
This strategy helps maintain fast feedback loops for documentation work while ensuring proper performance regression testing for code changes.
281+
232282
## Development Workflow
233283

234284
### 1. Issue-Driven Development

Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ uuid = { version = "1.18.0", features = ["v4", "serde"] }
3737

3838
[dev-dependencies]
3939
criterion = { version = "0.7", features = ["html_reports"] }
40+
pastey = "0.1"
4041

4142
[features]
4243
count-allocations = ["allocation-counter"]
@@ -57,8 +58,17 @@ harness = false
5758
name = "assign_neighbors_performance"
5859
harness = false
5960

61+
62+
[[bench]]
63+
name = "memory_scaling"
64+
harness = false
65+
66+
[[bench]]
67+
name = "triangulation_vs_hull_memory"
68+
harness = false
69+
6070
[[bench]]
61-
name = "small_scale_triangulation"
71+
name = "ci_performance_suite"
6272
harness = false
6373

6474
[lints.rust]

0 commit comments

Comments
 (0)