-
Notifications
You must be signed in to change notification settings - Fork 180
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
Do NOT use logger .disabled attribute until python 3.8 #389
Comments
@Mityuha Thanks for your report. I did some performance tests as you suggested on Py2.7, Py3.5, Py3.6, Py3.7, Py3.8. What I see is the performance improvement comes from the usage of cache since Py3.7. Not checking self.disabled attrubute in Py3.8.
Passing log_level=logging.WARNING (best with log_path=None) to Connection options will reduce the cumulative time for about 10%. So Py2.7, Py3.5, Py3.6 still take much longer time than Py3.7 and Py3.8. I also tried other two solutions for disable logging mentioned in https://bugs.python.org/issue36318. The performance (for all python versions) is even worse than using disable attribute. So I think vertica-python is doing the right thing so far. There is no performance enhancement we can do. |
@sitingren Thank you for your answer. It seems you are right about performance improvements since py3.7, but not since py3.8. Can you clarify some things?
So the last but not least thing I wanted to mention is very similar to pp. 1 and 2. The idea is that vertica is performed "as storage platform designed to handle large volumes of data". The key is large volumes. You mentioned, that there is no performance improvements you can do. I totally agree that it might be for not large volume of data. Is it correct about such amount of data for which vertica stated? |
Describe the issue
There is a method called isEnabledFor() inside python logging package's Logger class. Since python 3.8 this method takes into account self.disabled attrubute:
https://github.com/python/cpython/blob/3.8/Lib/logging/__init__.py#L1681
But before python 3.8 (e.g. 3.6) it does not:
https://github.com/python/cpython/blob/3.6/Lib/logging/__init__.py#L1681
What all written above does mean for vertica-python library?
Cursor iterate() and as a result fetchall() methods use fetchone() method under the hood. So the latter calls connection's read_message() method.
By default, there are no options to connection options, so the next line inside connection ctor executes:
vertica-python/vertica_python/vertica/connection.py
Line 263 in d98179f
And the next line inside read_message() method, that simple does log, works good since python 3.8 (I suggest):
vertica-python/vertica_python/vertica/connection.py
Line 640 in d98179f
because it almost immediately return.
But! We still remember, that before python 3.8 Logger's disable attribute does not make sense inside Logger's isEnabledFor().
It does take into account in other place, e.g. for python 3.6:
https://github.com/python/cpython/blob/3.6/Lib/logging/__init__.py#L1453
But there is a huge overhead before this line executes. The cProfile log (sorted by cumtime)
We see that logging takes 83 seconds, albeit it disabled.
And if I pass log_level=logging.WARNING (best with log_path=None) to Connection options, profiling now looks like this:
As we see, no logging overhead. It looks nice.
To reproduce
Workaround (before python 3.8)
Your version of the Python
Your version of vertica-python
Additional context
Logging disable attribute
https://bugs.python.org/issue36318
Possibly connected with #146
The text was updated successfully, but these errors were encountered: