main.js:2470-2475 constructs LogFileSink then calls enforceDirectoryCap() and purgeOlderThan(7); each internally re-walks ownedFiles() and re-measures directoryBytes (log-files-Bfo6ODqx.js:69,:90-96,:112). Additionally every log line opens/writes/closes the file (:106 comment "files are closed after every append").
Suggestion: take one ownedFiles() snapshot shared by constructor/cap/purge; move trimming off the critical path; keep a persistent append handle.
main.js:2470-2475 constructs LogFileSink then calls enforceDirectoryCap() and purgeOlderThan(7); each internally re-walks ownedFiles() and re-measures directoryBytes (log-files-Bfo6ODqx.js:69,:90-96,:112). Additionally every log line opens/writes/closes the file (:106 comment "files are closed after every append").
Suggestion: take one ownedFiles() snapshot shared by constructor/cap/purge; move trimming off the critical path; keep a persistent append handle.