You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Performance regression in urllib.proxy_bypass_environment #76589
Recently we update our environment from Python2.7.5 to Python2.7.13. Then one process's CPU usage grow from 15% to 70%. The cause is urllib.proxy_bypass_environment, the commit I wrote in bpo-26864. Our environments get a no_proxy environment variable which contains 4000+ items. See the performance difference:
cascading-controller:~ # time python2 -c 'import urllib; urllib.proxy_bypass_environment("1.1.1.1")'
real 0m1.134s
user 0m1.126s
sys 0m0.007s
cascading-controller:~ # time python2 -c 'import urllib; urllib.proxy_bypass_environment("1.1.1.1")'
real 0m0.037s
user 0m0.024s
sys 0m0.013s
Temporarily I increased regex cache size to 6000 and the CPU usage and time return to a reasonable range.
Activity
zhangyangyu commentedon Dec 22, 2017
Recently we update our environment from Python2.7.5 to Python2.7.13. Then one process's CPU usage grow from 15% to 70%. The cause is urllib.proxy_bypass_environment, the commit I wrote in bpo-26864. Our environments get a no_proxy environment variable which contains 4000+ items. See the performance difference:
cascading-controller:~ # time python2 -c 'import urllib; urllib.proxy_bypass_environment("1.1.1.1")'
real 0m1.134s
user 0m1.126s
sys 0m0.007s
cascading-controller:~ # time python2 -c 'import urllib; urllib.proxy_bypass_environment("1.1.1.1")'
real 0m0.037s
user 0m0.024s
sys 0m0.013s
Temporarily I increased regex cache size to 6000 and the CPU usage and time return to a reasonable range.
zhangyangyu commentedon Dec 25, 2017
Okay, the real performance is:
time python2 -c 'import urllib; urllib.proxy_bypass_environment("1.1.1.1")'
real 0m0.661s
user 0m0.654s
sys 0m0.007s
I compile it with a wrong option with the specific GCC version. But still really slow comparing to before.
zhangyangyu commentedon Apr 1, 2021
I think this issue has already been solved by bpo-39507. The time difference is:
before:
time python3 -c 'import urllib.request; urllib.request.proxy_bypass_environment("1.1.1.1")'
real 0m0.912s
user 0m0.902s
sys 0m0.010s
after:
time python3 -c 'import urllib.request; urllib.request.proxy_bypass_environment("1.1.1.1")'
real 0m0.105s
user 0m0.086s
sys 0m0.019s
zhangyangyu commentedon Apr 1, 2021
Sorry, it's bpo-39057