Skip to content

MAINT Reduce progress calculation & file-I/O cost - #3348

Merged
jbolor21 merged 5 commits into
microsoft:mainfrom
jbolor21:jbolor/memory_progress_calculation
Oct 22, 2026
Merged

jbolor21 merged 5 commits into
microsoft:mainfrom
jbolor21:jbolor/memory_progress_calculation

Conversation

@jbolor21

@jbolor21 jbolor21 commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Description

Follow up to #3197 - This PR reduces repeated work and overhead when reading scenario progress by moving file access off the event loop to keep the backend responsive, while preserving progress counts, retry accounting, resume behavior, and updates to finished runs.

Changes:

  • Adds a seed-to-unit lookup once per summary - reuses existing grouped attempts instead of searching all attack groups and results for every seed
  • Uses binary search for result paging - locates cursor in sorted cached results and selects the requested page rather than scanning the full history for matching results
  • Caches scorer metrics lookups - if file is unchanged then metrics are reused. Runs file checks & reads in worker thread so as not to block backend event loop
  • Refresh summaries when metrics or scorer identity changes including for completed, failed, or cancelled runs

Tests and Documentation

All existing tests pass, added new tests for:

  • Per-seed counts and avoiding repeated result scans.
  • Page boundaries, shared timestamps, bookmarks between results, and bounded bookmark lookup.
  • Metrics reuse across runs, file edits/deletion/recreation, and scorer changes.
  • Non-blocking metrics reads, cancellation cleanup, and file permission errors.

@jbolor21
jbolor21 marked this pull request as draft October 19, 2026 19:49
@jbolor21 jbolor21 changed the title [DRAFT]: MAINT Reduce progress calculation & file-I/O cost MAINT Reduce progress calculation & file-I/O cost Oct 19, 2026
@jbolor21
jbolor21 marked this pull request as ready for review October 19, 2026 20:39
Comment thread pyrit/backend/services/scenario_progress_read_model.py
@jbolor21
jbolor21 enabled auto-merge October 22, 2026 22:13
@jbolor21
jbolor21 added this pull request to the merge queue Oct 22, 2026
Merged via the queue into microsoft:main with commit 414c6bd Oct 22, 2026
63 of 65 checks passed
@jbolor21
jbolor21 deleted the jbolor/memory_progress_calculation branch October 22, 2026 22:50
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