Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .jules/bolt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 2024-05-24 - Ultralytics YOLO Synchronous Logging Overhead

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟑 Minor

Verify the date in the learning note.

The learning note is dated "2024-05-24", but this PR was created on "2026-04-08". If this represents when the learning was originally documented elsewhere, that's fine. Otherwise, consider updating to reflect the current optimization work.

πŸ€– Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.jules/bolt.md at line 1, The header "## 2024-05-24 - Ultralytics YOLO
Synchronous Logging Overhead" in .jules/bolt.md should be verified and either
updated or annotated: confirm whether "2024-05-24" is the original documentation
date or a mistake; if it’s incorrect, replace it with the PR date "2026-04-08"
(or the correct current date) in the header, or add a parenthetical note like
"(originally documented 2024-05-24)" to preserve provenance; update the header
text accordingly to "## 2026-04-08 - Ultralytics YOLO Synchronous Logging
Overhead" or add the provenance note so the date accurately reflects the context
of this PR.

**Learning:** Calling `model.predict()` in Ultralytics YOLO with the default settings causes synchronous stdout writes that can introduce blocking overhead, especially when called inside loops or handling multiple items.
**Action:** Always explicitly pass `verbose=False` to `model.predict()` unless debugging output is actively required. This prevents unnecessary I/O overhead.
4 changes: 4 additions & 0 deletions commonforms/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ def extract_widgets(
conf=confidence,
augment=False,
imgsz=ONNX_IMAGE_SIZE,
# Disable verbose to prevent synchronous stdout blocking overhead
verbose=False,
)
for p in pages
]
Expand All @@ -135,6 +137,8 @@ def extract_widgets(
augment=True,
imgsz=image_size,
device=self.device,
# Disable verbose to prevent synchronous stdout blocking overhead
verbose=False,
)

widgets = {}
Expand Down
9 changes: 9 additions & 0 deletions plan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
1. **Optimize YOLO `model.predict` in `commonforms/inference.py`**
- Pass `verbose=False` to `self.model.predict()` in both the fast-mode loop and the batch-mode call. This prevents synchronous stdout blocking overhead when processing many pages, making the inference step measurably faster.
- Add a comment explaining the optimization.
2. **Add a journal entry in `.jules/bolt.md`**
- Create/update `.jules/bolt.md` recording the performance bottleneck caused by Ultralytics YOLO synchronous stdout blocking overhead.
3. **Pre-commit checks**
- Complete pre-commit steps to ensure proper testing, verification, review, and reflection are done.
4. **Submit**
- Create a PR with title `⚑ Bolt: [performance improvement]` and the required description format.