-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
Poor performance on logging.RotatingFileHandler due to fix to #89564 #105623
Labels
performance
Performance or resource usage
stdlib
Python modules in the Lib dir
type-bug
An unexpected behavior, bug, or error
Comments
AlexWaygood
added
performance
Performance or resource usage
stdlib
Python modules in the Lib dir
labels
Jun 10, 2023
Do you want to propose a fix? (Pull request) |
@vstinner I will create a PR. |
zhatt
added a commit
to zhatt/cpython
that referenced
this issue
Jun 17, 2023
…ndler The check for whether the log file is a real file is expensive on NFS filesystems. This commit reorders the rollover condition checking to not do the file type check if the expected file size is less than the rotation threshold.
zhatt
added a commit
to zhatt/cpython
that referenced
this issue
Jun 17, 2023
…ndler The check for whether the log file is a real file is expensive on NFS filesystems. This commit reorders the rollover condition checking to not do the file type check if the expected file size is less than the rotation threshold.
zhatt
added a commit
to zhatt/cpython
that referenced
this issue
Jun 17, 2023
zhatt
added a commit
to zhatt/cpython
that referenced
this issue
Jun 20, 2023
zhatt
added a commit
to zhatt/cpython
that referenced
this issue
Jul 13, 2023
zhatt
added a commit
to zhatt/cpython
that referenced
this issue
Jun 27, 2024
serhiy-storchaka
pushed a commit
that referenced
this issue
Jun 27, 2024
…H-105887) The check for whether the log file is a real file is expensive on NFS filesystems. This commit reorders the rollover condition checking to not do the file type check if the expected file size is less than the rotation threshold. Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this issue
Jun 28, 2024
…ndler (pythonGH-105887) The check for whether the log file is a real file is expensive on NFS filesystems. This commit reorders the rollover condition checking to not do the file type check if the expected file size is less than the rotation threshold. (cherry picked from commit e9b4ec6) Co-authored-by: Craig Robson <craig@zhatt.com> Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this issue
Jun 28, 2024
…ndler (pythonGH-105887) The check for whether the log file is a real file is expensive on NFS filesystems. This commit reorders the rollover condition checking to not do the file type check if the expected file size is less than the rotation threshold. (cherry picked from commit e9b4ec6) Co-authored-by: Craig Robson <craig@zhatt.com> Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
serhiy-storchaka
pushed a commit
that referenced
this issue
Jun 28, 2024
…andler (GH-105887) (GH-121116) The check for whether the log file is a real file is expensive on NFS filesystems. This commit reorders the rollover condition checking to not do the file type check if the expected file size is less than the rotation threshold. (cherry picked from commit e9b4ec6) Co-authored-by: Craig Robson <craig@zhatt.com> Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
serhiy-storchaka
pushed a commit
that referenced
this issue
Jun 28, 2024
…andler (GH-105887) (GH-121117) The check for whether the log file is a real file is expensive on NFS filesystems. This commit reorders the rollover condition checking to not do the file type check if the expected file size is less than the rotation threshold. (cherry picked from commit e9b4ec6) Co-authored-by: Craig Robson <craig@zhatt.com> Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
mrahtz
pushed a commit
to mrahtz/cpython
that referenced
this issue
Jun 30, 2024
…ndler (pythonGH-105887) The check for whether the log file is a real file is expensive on NFS filesystems. This commit reorders the rollover condition checking to not do the file type check if the expected file size is less than the rotation threshold. Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
noahbkim
pushed a commit
to hudson-trading/cpython
that referenced
this issue
Jul 11, 2024
…ndler (pythonGH-105887) The check for whether the log file is a real file is expensive on NFS filesystems. This commit reorders the rollover condition checking to not do the file type check if the expected file size is less than the rotation threshold. Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
estyxx
pushed a commit
to estyxx/cpython
that referenced
this issue
Jul 17, 2024
…ndler (pythonGH-105887) The check for whether the log file is a real file is expensive on NFS filesystems. This commit reorders the rollover condition checking to not do the file type check if the expected file size is less than the rotation threshold. Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
performance
Performance or resource usage
stdlib
Python modules in the Lib dir
type-bug
An unexpected behavior, bug, or error
The fix to #89564 produced a significant performance degradation when logs are on an NFS filesystem. The fix for #89564 was for a bug found with the TimedRotatingFileHandler but an fix was added to the sized base file rotator too.
Here is the RotatingFileHandler.shouldRollover() function. The os.path.exists() and os.path.isfile() are very slow on NFS filesystems. On Linux systems, if os.path.isfile() returns False, the self.stream.seek(0,2) will always return 0 because the file is not seekable so non-isfile() files will never be rotated unless the rotation size is smaller than the message size.
Since, the rollover could be triggered with a very large msg and small maxBytes. Moving the exists() and isfile() check to inside the
if self.stream.tell()...
would cover that case and not run the expensive status operations with a correctly configured logger except when the rotation is needed. That is similar to the fix made to the TimedRotatingFileHandler in #96159.Linked PRs
The text was updated successfully, but these errors were encountered: