-
Notifications
You must be signed in to change notification settings - Fork 600
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Keep the log fd, don't re-open logfile in every logs #906
base: unstable
Are you sure you want to change the base?
Conversation
Currently in serverLog, we fopen and fclose the logfile in every call, if the log prints too much, it will waste performance. Also frequent open may cause blocking in some caes. We have encountered open blocking for hundreds of milliseconds to seconds. In this PR, we keep the log fd, and only re-open it when dir changed. This also improve performance, using benchmark DEBUG log shows that it improves the performance by 3 times. Signed-off-by: Binbin <[email protected]>
Signed-off-by: Binbin <[email protected]>
Signed-off-by: Binbin <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## unstable #906 +/- ##
=========================================
Coverage 70.34% 70.35%
=========================================
Files 112 112
Lines 61490 61492 +2
=========================================
+ Hits 43258 43265 +7
+ Misses 18232 18227 -5
|
@madolson @zuiderkwast @PingXie do you guys want to takes a look with this? i would like to include it in the RC3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we want it in 8.0, it's better in rc2 than later.
This is a breaking change IIRC, if there are existing mechanisms for log rotation we need to send a signal to the process to close and re-open the log. We discussed this at length in Redis, but never committed to it. |
Good point @madolson. I think we can't do this change without a more advanced solution then. We can use ionotify on linux and kqueue on BSD/MacOS to watch the file and be notified when it is renamed. Then we close and reopen it. Fallback to the old behaviour if no watch method is available. |
ok, i see the point, indeed in this case, we need to find a way to re-open the file. |
That is great information. I think it would be very helpful if we could leave this context in |
Currently in serverLog, we fopen and fclose the logfile in every
call, if the log prints too much, it will waste performance. Also
frequent open may cause blocking in some caes, like doing a big
rename in the same dir (like rename the bgsave temp RDB).
In this PR, we keep the log fd, and only re-open it when dir changed.
This also improve performance, using benchmark DEBUG log shows that
it improves the performance by 3 times.