Skip to content

Speed up app startup (use rename instead of copy for log file rotation)#30312

Open
futpib wants to merge 1 commit intotelegramdesktop:devfrom
futpib:log-rename-rotation
Open

Speed up app startup (use rename instead of copy for log file rotation)#30312
futpib wants to merge 1 commit intotelegramdesktop:devfrom
futpib:log-rename-rotation

Conversation

@futpib
Copy link
Contributor

@futpib futpib commented Feb 18, 2026

Replace the expensive file copy in Logs::instanceChecked() with an atomic rename. The old code copied log_startX.txt to log.txt then deleted the original, which took ~83ms of synchronous I/O. A simple rename on the same filesystem is nearly instant (~0.3ms).

Admittedly my logs were larger than usual because i added a ton of PROFILE_LOG's

@futpib futpib changed the title Use rename instead of copy for log file rotation at startup Feb 18, 2026
@john-preston
Copy link
Member

@futpib Nice, thanks for all your findings, I hope to review them soon-ish.

@futpib futpib requested a review from ilya-fedin February 18, 2026 14:27
@ilya-fedin
Copy link
Contributor

Could you squash?

@futpib futpib force-pushed the log-rename-rotation branch from 9ccfc16 to cc85490 Compare February 18, 2026 14:30
@futpib
Copy link
Contributor Author

futpib commented Feb 18, 2026

Squashed

Replace the expensive file copy in Logs::instanceChecked() with an
atomic rename. The old code copied log_startX.txt to log.txt then
deleted the original, which took ~83ms of synchronous I/O. A simple
rename on the same filesystem is nearly instant (~0.3ms).
@futpib futpib force-pushed the log-rename-rotation branch from cc85490 to 1c7e95b Compare February 28, 2026 23:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants