perf: optimize disk I/O by batching writes in _process_batch_worker - #13701
Open
EMREYSLCY wants to merge 1 commit into
Open
perf: optimize disk I/O by batching writes in _process_batch_worker#13701EMREYSLCY wants to merge 1 commit into
EMREYSLCY wants to merge 1 commit into
Conversation
teknium1
reviewed
Jul 12, 2026
teknium1
left a comment
Contributor
There was a problem hiding this comment.
Thanks for targeting repeated output-file opens in the batch worker.
Problems
batch_runner.py:474on this PR appendstrajectory_entryoutside theif result["success"] and result["trajectory"]block that creates it at lines 441-471. A failed first prompt therefore raisesUnboundLocalError; a failure after a success appends the prior entry again.- The PR changes no tests. The current worker test at
tests/test_batch_runner_checkpoint.py:160-186covers a successful no-reasoning discard, not a failed prompt in this path.
Suggested changes
- Keep the append inside the successful-trajectory block.
- Add a regression test with failed and successful worker results, asserting only successful entries are written.
Automated hermes-sweeper review.
| with open(batch_output_file, 'a', encoding='utf-8') as f: | ||
| f.write(json.dumps(trajectory_entry, ensure_ascii=False) + "\n") | ||
| # Accumulate results in memory instead of writing to disk every time | ||
| batch_results_to_write.append(trajectory_entry) |
Contributor
There was a problem hiding this comment.
trajectory_entry is only assigned in the successful-result guard above. A failed first prompt raises UnboundLocalError here; after a prior success, this appends that prior entry again. Keep this append inside the guard.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Related Issue
Fixes #
Type of Change
Changes Made
How to Test
Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AFor New Skills
hermes --toolsets skills -q "Use the X skill to do Y"Screenshots / Logs