Skip to content

Fix LogDrawer slowdown from unbounded line accumulation#301

Merged
davidfstr merged 2 commits intomainfrom
copilot/fix-logdrawer-new-line-issue
Mar 22, 2026
Merged

Fix LogDrawer slowdown from unbounded line accumulation#301
davidfstr merged 2 commits intomainfrom
copilot/fix-logdrawer-new-line-issue

Conversation

Copy link
Contributor

Copilot AI commented Mar 22, 2026

LogDrawer never trimmed old lines from its RichTextCtrl, so each append got progressively slower as the log grew without bound.

Changes

  • log_drawer.py — Add _MAX_LINE_COUNT = 5000. After each batch of text is written to the textarea, trim leading lines when the count exceeds the limit using wxPython's efficient positional deletion:
    line_count = textarea.GetNumberOfLines()
    if line_count > _MAX_LINE_COUNT:
        lines_to_remove = line_count - _MAX_LINE_COUNT
        end_of_removed = textarea.XYToPosition(0, lines_to_remove)
        textarea.Remove(0, end_of_removed)
  • test_log_drawer.py — Add skipped stub test_when_write_many_lines_to_writer_beyond_max_then_leading_lines_trimmed, consistent with existing stubs in the file.
  • RELEASE_NOTES.md — Document under a new "Performance improvements" section.
Original prompt

Fix the depicted issue where LogDrawer appends new lines slower and slower over time, because old lines are never cleared out.

Probably want to define a (generous) max line count, perhaps 5,000 lines, and configure the text area to remove leading lines when count exceeds that amount. Hopefully wxPython provides APIs that allow line ranges in a text area to be deleted efficiently.

The user has attached the following file paths as relevant context:

  • .github/copilot-instructions.md

Created from VS Code.


📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.

Copilot AI changed the title [WIP] Fix LogDrawer appending new lines performance issue Fix LogDrawer slowdown from unbounded line accumulation Mar 22, 2026
Copilot AI requested a review from davidfstr March 22, 2026 14:49
@davidfstr davidfstr force-pushed the copilot/fix-logdrawer-new-line-issue branch from 702d6f0 to 9d1d5ea Compare March 22, 2026 20:41
@davidfstr davidfstr marked this pull request as ready for review March 22, 2026 20:42
@davidfstr davidfstr merged commit bea5d8b into main Mar 22, 2026
6 checks passed
@davidfstr davidfstr deleted the copilot/fix-logdrawer-new-line-issue branch March 22, 2026 20:42
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