Skip to content

perf: markers grouped by patch with one sort, and marker counts from one histogram - #74

Merged
max-models merged 13 commits into
develfrom
claude/tree-d3d-poison-maxwell-atyjic
Nov 25, 2026
Merged

max-models merged 13 commits into
develfrom
claude/tree-d3d-poison-maxwell-atyjic

Conversation

@max-models

@max-models max-models commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • deposit, interpolate and _owners (behind owner and migrate) used to find each patch's markers with np.flatnonzero(found == number): one scan of all markers per patch, so 386 × 200k comparisons on the quadtree benchmark. _by_patch sorts the patch numbers once (stable) and yields each patch's indices, in the order of the patches as before.
  • marker_counts histograms the finest requested level once and sums blocks of cells into the coarser levels, instead of one histogramdd per level. Finer levels split coarse cells evenly, graded axes included, so the counts are the same; a new test checks them against per-level histograms on uniform and graded axes.
  • benchmarks/quadtree now runs one untimed cycle first. The compiled kernels load at their first call (580 ms for the first deposit), and the earlier runs counted that in their first timed step.
  • RESULTS.md compares devel with this branch together with perf: build a CopyPlan with array operations over the copies mpiarray#73 (a CopyPlan built with array operations).

Serial, median of 3, ms per step:

mesh devel this + mpiarray#73
clusters 327 246 (−25%)
clusters cut to 16 cells 682 511 (−25%)
quadtree, block 8 1263 928 (−27%)
quadtree, block 16 621 468 (−25%)
quadtree, block 32 525 419 (−20%)

Tagging gets three times faster. With blocks of 8, gather goes from 131 to 69 ms, migrate from 66 to 36, halos from 266 to 204. The changes here don't depend on the mpiarray PR; the halo and regrid numbers do.

Checklist

  • pre-commit run and pytest pass (730 passed locally)
  • New code has docstrings and tests
  • The docs (docs/, tutorials or README.qmd) are updated where the behaviour changed
  • The commit messages follow Conventional Commits (feat:, fix:, docs:, ...)

@max-models
max-models merged commit d7149de into devel Nov 25, 2026
27 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.

1 participant