[stable-34.0] Faster File Provider Log Rotation - #10768
Merged
Merged
Conversation
`rotateLogFileIfNeeded()` runs before every single line and used to `stat` the log file each time to decide whether to rotate. `write(...)` then called `synchronize()` after every line. Both are syscalls, and both sit on an actor that every hot path in the extension awaits, so a burst of log lines became that many serialized disk operations in front of unrelated work. A bulk materialisation emits tens of thousands of lines: one measured pass produced 28,334 of them in seven minutes. Track the bytes written instead of asking the file system. The counter is exact because this actor is the only writer and each file is created empty. Drop the per-line fsync: `FileHandle.write(contentsOf:)` is an unbuffered `write(2)`, so the line is in the file and readable the moment it returns, and the fsync only bought durability against power loss, which a diagnostic log does not need. Rotation still flushes before closing a file. Both substitutions are safe only because of properties that are easy to break later and invisible when broken, so each gets a test: the counter agrees with the file byte for byte, an unsynchronised line is readable as soon as the write returns, and rotation restarts the counter rather than carrying the closed file's total over. Reaching those from a test needs somewhere to write, and a test bundle has no application group container. `init` therefore takes an optional logs directory and a maximum file size, mirroring `FilesDatabaseManager(databaseDirectory:)`. Both default to today's behaviour. Assisted-by: Claude Code:claude-opus-5 Signed-off-by: Julius van der Vaart <julius@vanderva.art>
backportbot
Bot
requested review from
camilasan,
claucambra,
i2h3,
mgallien and
nilsding
as code owners
September 8, 2026 14:57
Contributor
|
Artifact containing the AppImage: nextcloud-appimage-pr-10768.zip Digest: To test this change/fix you can download the above artifact file, unzip it, and run it. Please make sure to quit your existing Nextcloud app and backup your data. |
|
claucambra
approved these changes
Sep 8, 2026
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.



Backport of PR #10741