-
-
Notifications
You must be signed in to change notification settings - Fork 29.4k
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
Significant performance degradation in logging.TimedRotatingFileHandler due to fix to #89564 #96159
Comments
Well, the logic belongs in
As you're hitting the performance issue in your environment, I invite you to consider making a patch using one or more of the above suggestions and then testing the performance impact, and if a solution is found which is acceptable, working up a PR with that patch. |
In our application we know for a fact that the logfile is not a special file, so the new check is not required for us. We already had our own subclass of TimedRotatingFileHandler, so we have fixed this for ourselves by simply giving our subclass a shouldRollover method containing a copy of the original code. We no longer suffer from this issue because we are no longer using the problematic code. I raised this defect to try to be helpful for other people who hit the same issue. |
OK, thanks - that was thoughtful of you. I'll close this issue then, but aim to remember if a performance issue is logged in this area. Of course, that "problematic code" was added because its absence caused problems in other scenarios 🙂 |
I do think this is something that should be fixed in the standard library. I will create a PR for it. |
…dRotatingFileHandler due to fix to python#89564
…otatingFileHandler due to fix to python#89564 Only check for special files when the rollover time has passed, rather than cheking on every log message.
Thanks, Duncan. As you're best placed to test the result of the fix, I was hoping for this. |
…medRotat… (pythonGH-96182) (cherry picked from commit 1499d73) Co-authored-by: Duncan Grisby <duncan-github@grisby.org>
…medRotat… (pythonGH-96182) (cherry picked from commit 1499d73) Co-authored-by: Duncan Grisby <duncan-github@grisby.org>
The fix to #89564 was to add two file checks to the shouldRollover() method of logging.TimedRotatingFileHandler and RotatingFileHandler (see 62a6677 )
This means that every single log call now does two stat() calls to the log file, which is quite expensive. If the log file is stored on NFS, those stat() calls become extremely expensive. In our application it caused a dramatic (and hard to diagnose) performance loss.
It would be better if shouldRollover() was reverted to its previous implementation, and the check for special files was moved into doRollover(). That would mean the cost of the additional checks was only incurred when there is a rollover to do.
The text was updated successfully, but these errors were encountered: