Skip to content

Performance regression in urllib.proxy_bypass_environment #76589

Closed

Description

@zhangyangyu
BPO 32408
Nosy @serhiy-storchaka, @zhangyangyu

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2021-04-01.06:54:17.288>
created_at = <Date 2017-12-22.06:14:04.974>
labels = ['3.8', '3.7', 'library', 'performance']
title = 'Performance regression in urllib.proxy_bypass_environment'
updated_at = <Date 2021-04-01.06:56:13.221>
user = 'https://github.com/zhangyangyu'

bugs.python.org fields:

activity = <Date 2021-04-01.06:56:13.221>
actor = 'xiang.zhang'
assignee = 'none'
closed = True
closed_date = <Date 2021-04-01.06:54:17.288>
closer = 'xiang.zhang'
components = ['Library (Lib)']
creation = <Date 2017-12-22.06:14:04.974>
creator = 'xiang.zhang'
dependencies = []
files = []
hgrepos = []
issue_num = 32408
keywords = []
message_count = 4.0
messages = ['308924', '309025', '389957', '389958']
nosy_count = 2.0
nosy_names = ['serhiy.storchaka', 'xiang.zhang']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'performance'
url = 'https://bugs.python.org/issue32408'
versions = ['Python 2.7', 'Python 3.6', 'Python 3.7', 'Python 3.8']

Activity

  1. zhangyangyu commented on Dec 22, 2017

    @zhangyangyu
    MemberAuthor

    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.

  2. added
    3.7 (EOL)
    3.8 (EOL)
    stdlib
    performance
    on Dec 22, 2017
  3. zhangyangyu commented on Dec 25, 2017

    @zhangyangyu
    MemberAuthor

    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.

  4. zhangyangyu commented on Apr 1, 2021

    @zhangyangyu
    MemberAuthor

    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

  5. zhangyangyu commented on Apr 1, 2021

    @zhangyangyu
    MemberAuthor

    Sorry, it's bpo-39057

  6. transferred this issue fromon Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.7 (EOL)3.8 (EOL)performancestdlib

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions