Fix multi-second UI freeze when toggling severity filters on large logs - #22
Open
Schogol wants to merge 3 commits into
Open
Fix multi-second UI freeze when toggling severity filters on large logs#22Schogol wants to merge 3 commits into
Schogol wants to merge 3 commits into
Conversation
Port of the flat-filter-proxy fix onto the current CMake/Qt6 codebase
(headers under include/, upstream's modernized logfilter).
Replace QSortFilterProxyModel with a purpose-built flat filter proxy.
LogFilter keeps a sorted index of accepted source rows; a severity toggle
rebuilds that index in a single pass and emits layoutChanged (preserving
selection) instead of re-testing every row through the generic proxy
machinery. Streaming inserts/removals stay incremental and mapToSource
becomes an O(1) lookup.
- logfilter.{h,cpp}: rewrite LogFilter as a flat QAbstractProxyModel;
keep the highlight data() override using Qt::ForegroundRole/BackgroundRole.
- logmap.cpp: repaint the logmap on layoutChanged/modelReset.
- mainwindow.cpp: drop the now-obsolete setFilterCaseSensitivity call.
Measured on the Qt6/CMake build, 100k rows, hide-info toggle:
~5350 ms -> ~8 ms. Validated with QAbstractItemModelTester (no
consistency warnings).
Author
|
Before and after comparison: Old Loglite: New Loglite |
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.
Problem
On large logs, clicking the severity filter buttons (show/hide notice/info) froze the UI for several seconds.
LogFilterwas aQSortFilterProxyModel, so each toggle re-tested every source row and rebuilt the whole mapping, emitting a storm of granular row-insert/remove signals that the table and header processed one at a time - effectively O(N²) with the view attached.Change
Replace
QSortFilterProxyModelwith a purpose-built flat filter proxy:m_proxyToSource).layoutChanged(selection preserved via persistent indexes) instead of re-testing every row.mapToSourceis O(1).layoutChanged/modelReset(filter changes no longer arrive as row insert/remove).setFilterCaseSensitivitycall.Results
QAbstractItemModelTester(no consistency warnings) across inserts, streaming-while-filtered, removal, clear, severity toggles, and text filtering.Files changed
src/logfilter.cppinclude/logfilter.hsrc/logmap.cppsrc/mainwindow.cppclients/qtclient/qloglitelogger.cppNote:
clients/qtclient/qloglitelogger.cppis an unrelated one-line cleanup (removes a duplicate channelfillString) that rode along on the branch. Happy to drop it for a fix-only PR if preferred.Disclaimer: Issue encountered, reproduced by me. Fix created with help by Claude. Fix has been live tested by me for a bit now and I've not noticed any issues