Skip to content

perf(core): offload score_blocks_mig O(K²) loop to spawn_blocking#3398

Merged
bug-ops merged 1 commit intomainfrom
score-blocks-spawn-blocking
Apr 25, 2026
Merged

perf(core): offload score_blocks_mig O(K²) loop to spawn_blocking#3398
bug-ops merged 1 commit intomainfrom
score-blocks-spawn-blocking

Conversation

@bug-ops
Copy link
Copy Markdown
Owner

@bug-ops bug-ops commented Apr 25, 2026

Summary

  • Wraps the O(K²) pairwise MIG scoring loop in run_focus_auto_consolidation with tokio::task::spawn_blocking to prevent blocking the async executor during long-session consolidation passes.
  • Messages and task goal are cloned before entering the blocking closure; a fresh TokenCounter is constructed inside it.
  • No change to score_blocks_mig signature or the sync call site in prune_tool_outputs_mig (which is already a sync fn).

Closes #3386

Test plan

  • cargo build -p zeph-core — compiles cleanly
  • cargo +nightly fmt --check — no formatting issues
  • cargo clippy -p zeph-core -- -D warnings — zero warnings
  • cargo nextest run --workspace --lib --bins — 8475 tests pass, 0 failures

@github-actions github-actions Bot added documentation Improvements or additions to documentation rust Rust code changes core zeph-core crate performance Performance improvements size/S Small PR (11-50 lines) labels Apr 25, 2026
@bug-ops bug-ops enabled auto-merge (squash) April 25, 2026 10:52
)

Clone messages and task goal before entering spawn_blocking so the
pairwise redundancy computation does not occupy the async executor
during long-session focus auto-consolidation passes.
@bug-ops bug-ops force-pushed the score-blocks-spawn-blocking branch from 5527842 to 396b2b6 Compare April 25, 2026 10:52
@bug-ops bug-ops merged commit b39661e into main Apr 25, 2026
32 checks passed
@bug-ops bug-ops deleted the score-blocks-spawn-blocking branch April 25, 2026 10:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core zeph-core crate documentation Improvements or additions to documentation performance Performance improvements rust Rust code changes size/S Small PR (11-50 lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perf(core): offload score_blocks_mig O(K2) pairwise scoring to spawn_blocking

1 participant