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.
Description of issue
Previously, we had an issue where the Logs tab would freeze when loading it for the first time. This would happen, because it takes a long time to read and parse a large number of logs.
How the issue was solved
I changes how LogsController parses logs. Previously, it parsed all the logs in one long for-loop. Now, it parses the logs in batches of 128 logs.
When the
add_data_to_record(..))
method is called, it creates an idle function to parse logs when nothing else is happening. This means that, whenever the application is in use (for example if the user is clicking buttons), the idle function waits to be called. Eventually, when the function is finally called: it only parses 128 logs, and waits until the main loop is ready to call it again.What this means
Now the Logs tab can be populated without freezing the application.
Any lingering issues
I did some research into using cursors, to control which logs journalctl reads. Cursors can be read directly from a log's json value. I think this approach could be helpful when refreshing the tab to look for more logs. It would be better to only look for logs after the most recent cursor, in addition to the changes made in this PR.