Skip to content

[stable-34.0] Faster File Provider Log Rotation - #10768

Merged
i2h3 merged 1 commit into
stable-34.0from
backport/10741/stable-34.0
Sep 8, 2026
Merged

[stable-34.0] Faster File Provider Log Rotation#10768
i2h3 merged 1 commit into
stable-34.0from
backport/10741/stable-34.0

Conversation

@backportbot

@backportbot backportbot Bot commented Sep 8, 2026

Copy link
Copy Markdown

Backport of PR #10741

`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
backportbot Bot requested review from claucambra and i2h3 September 8, 2026 14:57
@backportbot backportbot Bot added os: 馃崕 macOS Apple macOS, formerly also known as OS X 3. to review Performance 馃殌 feature: 馃搧 file provider macOS File Provider Extension, more general also known as virtual file system. labels Sep 8, 2026
@backportbot backportbot Bot added this to the 34.0.4 milestone Sep 8, 2026
@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Artifact containing the AppImage: nextcloud-appimage-pr-10768.zip

Digest: sha256:3f791969f5c0ffe907245a1e3a620e3f5de93b18acc9e21f0a06380d93555204

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.

@sonarqubecloud

sonarqubecloud Bot commented Sep 8, 2026

Copy link
Copy Markdown

@i2h3
i2h3 enabled auto-merge September 8, 2026 16:05
@i2h3
i2h3 merged commit c8d4c98 into stable-34.0 Sep 8, 2026
20 checks passed
@i2h3
i2h3 deleted the backport/10741/stable-34.0 branch September 8, 2026 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review feature: 馃搧 file provider macOS File Provider Extension, more general also known as virtual file system. os: 馃崕 macOS Apple macOS, formerly also known as OS X Performance 馃殌

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants