-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
iter_entry_point often spending a lot of time on parsing a dummy requirements string #1132
Comments
Avoiding the call to Requirements.parse when extras is empty (patch below), leads to a significant improvement of iter_entry_points performance.
test:
(with 17 entry points in the "openstack.cli.extension" group) time with original code: 0.969233036041 |
(a possibly better fix may possibly be, in |
In the case where an EntryPoint is created with no extra, a Requirement object is instanciated with a dummy requirement string 'x[]', which incurs a useless significant cost due to the use of pyparsing to parse this string. This change skips the instanciation of a Requirements objects in the case where extra is empty. See github issue pypa#1132 for more details, including information on the performance improvement brought by this change.
I've been unable to replicate your findings. When I try running timeit on iter_entry_points, I'm seeing results in the ~0.09 ballpark:
Is there a test that can replicate the undesirable behavior without a third-party package? If not, can you describe steps to create an environment that does readily show the slow behavior? |
When investigating a performance issue on a tool that makes use of setuptools entry points [1], profiling pointed at iter_entry_points as a hot point (see flamegraph attached to [1]), with iter_entry_points surprisingly spending a lot of time in pyparsing.
Digging further it appears that when an EntryPoint is created, even without anything in "extras", Requirements.parse is still called (see [2]) and ultimately results in parsing a "dummy" (because mostly empty) requirements string: "x[]".
[1] https://bugs.launchpad.net/python-openstackclient/+bug/1702483
[2] https://github.com/pypa/setuptools/blob/master/pkg_resources/__init__.py#L2289
The text was updated successfully, but these errors were encountered: