Skip to content

Reuse exact Costes thresholds across object sets in one step - #186

Merged
trissim merged 2 commits into
mainfrom
codex/perf-coloc-step-cache
Sep 29, 2026
Merged

trissim merged 2 commits into
mainfrom
codex/perf-coloc-step-cache

Conversation

@trissim

@trissim trissim commented Sep 29, 2026 •

Copy link
Copy Markdown
Collaborator

Problem and behavior

The advanced and beginner segmentation tutorials repeat Costes threshold calculation for identical image-pair pixels across object sets. A real 1w_1t profile found 180 object-colocalization calls but only 40 distinct selected-pixel pairs; threshold work took 3.999 seconds. The image payload is rebuilt between object sets, so its identity cannot safely identify reusable thresholds.

This change shares thresholds for one FunctionStep invocation. The existing Costes batch authority now keys exact selected-pixel content plus method, scale, and backend selection; the CellProfiler module executor passes the step-owned value to each object measurement. The cache is released at the step boundary and is absent from compiled parameters. The separate batch executor metadata issue #176 remains open.

Closes #185. Stacked on #183.

Evidence

  • Interleaved warmed control/candidate/candidate/control runs on the two affected tutorials: execution 17.593 → 14.991 seconds (-2.602 s); total 32.004 → 29.347 seconds (-2.657 s). Both candidate runs produced all 15 result files byte-identically to control.
  • An independently profiled pair: Costes threshold phase 3.999 → 1.400 seconds over 180 calls; object-colocalization total 5.217 → 2.620 seconds.
  • Warmed official30 fresh-server sweep: 30/30 succeeded and 110/110 output files matched byte-for-byte. Summed execution 89.286 → 87.857 seconds; summed measured total 261.691 → 260.928 seconds. Other full sweeps varied materially in unaffected cases, so this small suite-wide net difference is not claimed as a stable global speedup. The targeted pair and its profiled mechanism provide the stronger evidence.
  • Focused isolated-branch tests: 623 passed. Black, Ruff E9/F63/F7, and whitespace checks passed. Source and plot data are retained in benchmark/results/perf_coloc_step_cache_20260929/.

Validation follow-up: the shared CellProfiler test context now supplies one runtime step value per type, matching the production context used by the Costes cache. This fixes the previously failing composed-image runtime-adapter test; the test passes in this PR checkout.

@trissim
trissim marked this pull request as ready for review September 29, 2026 13:35
@trissim
trissim changed the base branch from codex/perf-fast-completion-poll to main September 29, 2026 17:54
@trissim
trissim merged commit 65a64a3 into main Sep 29, 2026
1 check failed
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.

Reuse identical Costes thresholds across object sets in one step

1 participant