Skip to content
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

DNM: Improve performance of starting client responses #10036

Closed
wants to merge 1 commit into from

Conversation

bdraco
Copy link
Member

@bdraco bdraco commented Nov 24, 2024

No description provided.

Copy link

codecov bot commented Nov 24, 2024

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
3177 1 3176 29
View the top 1 failed tests by shortest run time
tests.test_client_session test_client_session_timeout_zero[pyloop]
Stack Traces | 0.183s run time
create_mocked_conn = <function create_mocked_conn.<locals>._proto_factory at 0x7fa2ecd57f40>

    #x1B[0m#x1B[94masync#x1B[39;49;00m #x1B[94mdef#x1B[39;49;00m #x1B[92mtest_client_session_timeout_zero#x1B[39;49;00m(#x1B[90m#x1B[39;49;00m
        create_mocked_conn: Callable[[], ResponseHandler]#x1B[90m#x1B[39;49;00m
    ) -> #x1B[94mNone#x1B[39;49;00m:#x1B[90m#x1B[39;49;00m
        #x1B[94masync#x1B[39;49;00m #x1B[94mdef#x1B[39;49;00m #x1B[92mcreate_connection#x1B[39;49;00m(#x1B[90m#x1B[39;49;00m
            req: #x1B[96mobject#x1B[39;49;00m, traces: #x1B[96mobject#x1B[39;49;00m, timeout: #x1B[96mobject#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
        ) -> ResponseHandler:#x1B[90m#x1B[39;49;00m
            #x1B[94mawait#x1B[39;49;00m asyncio.sleep(#x1B[94m0.01#x1B[39;49;00m)#x1B[90m#x1B[39;49;00m
            conn = create_mocked_conn()#x1B[90m#x1B[39;49;00m
            conn.connected = #x1B[94mTrue#x1B[39;49;00m  #x1B[90m# type: ignore[misc]#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
            #x1B[94massert#x1B[39;49;00m conn.transport #x1B[95mis#x1B[39;49;00m #x1B[95mnot#x1B[39;49;00m #x1B[94mNone#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
            conn.transport.is_closing.return_value = #x1B[94mFalse#x1B[39;49;00m  #x1B[90m# type: ignore[attr-defined]#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
            msg = mock.create_autospec(RawResponseMessage, spec_set=#x1B[94mTrue#x1B[39;49;00m, code=#x1B[94m200#x1B[39;49;00m)#x1B[90m#x1B[39;49;00m
            conn.read.return_value = (msg, mock.Mock())  #x1B[90m# type: ignore[attr-defined]#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
            #x1B[94mreturn#x1B[39;49;00m conn#x1B[90m#x1B[39;49;00m
    #x1B[90m#x1B[39;49;00m
        timeout = client.ClientTimeout(total=#x1B[94m10#x1B[39;49;00m, connect=#x1B[94m0#x1B[39;49;00m, sock_connect=#x1B[94m0#x1B[39;49;00m, sock_read=#x1B[94m0#x1B[39;49;00m)#x1B[90m#x1B[39;49;00m
        #x1B[94masync#x1B[39;49;00m #x1B[94mwith#x1B[39;49;00m ClientSession(timeout=timeout) #x1B[94mas#x1B[39;49;00m session:#x1B[90m#x1B[39;49;00m
            #x1B[94mwith#x1B[39;49;00m mock.patch.object(#x1B[90m#x1B[39;49;00m
                session._connector, #x1B[33m"#x1B[39;49;00m#x1B[33m_create_connection#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, create_connection#x1B[90m#x1B[39;49;00m
            ):#x1B[90m#x1B[39;49;00m
                #x1B[94mtry#x1B[39;49;00m:#x1B[90m#x1B[39;49;00m
>                   resp = #x1B[94mawait#x1B[39;49;00m session.get(#x1B[33m"#x1B[39;49;00m#x1B[33mhttp://example.com#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m)#x1B[90m#x1B[39;49;00m

create_connection = <function test_client_session_timeout_zero.<locals>.create_connection at 0x7fa2ecd56170>
create_mocked_conn = <function create_mocked_conn.<locals>._proto_factory at 0x7fa2ecd57f40>
session    = <aiohttp.client.ClientSession object at 0x7fa2e4cd3d40>
timeout    = ClientTimeout(total=10, connect=0, sock_read=0, sock_connect=0, ceil_threshold=5)

#x1B[1m#x1B[31mtests/test_client_session.py#x1B[0m:1073: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31maiohttp/client.py#x1B[0m:671: in _request
    #x1B[0m#x1B[94mawait#x1B[39;49;00m resp.start(conn)#x1B[90m#x1B[39;49;00m
        all_cookies = <SimpleCookie: >
        allow_redirects = True
        auth       = None
        auth_from_url = None
        auto_decompress = True
        chunked    = None
        compress   = False
        conn       = Connection<ConnectionKey(host='example.com', port=80, is_ssl=False, ssl=True, proxy=None, proxy_auth=None, proxy_headers_hash=None)>
        cookies    = None
        data       = None
        expect100  = False
        handle     = None
        headers    = <CIMultiDict()>
        history    = []
        json       = None
        max_field_size = 8190
        max_line_size = 8190
        max_redirects = 10
        method     = 'GET'
        params     = {}
        proxy      = None
        proxy_auth = None
        proxy_headers = None
        raise_for_status = None
        read_bufsize = 65536
        read_until_eof = True
        real_timeout = ClientTimeout(total=10, connect=0, sock_read=0, sock_connect=0, ceil_threshold=5)
        redirects  = 0
        req        = <aiohttp.client_reqrep.ClientRequest object at 0x7fa2e59b3160>
        resp       = <ClientResponse(http://example.com) [None None]>
None

        retry_persistent_connection = True
        self       = <aiohttp.client.ClientSession object at 0x7fa2e4cd3d40>
        server_hostname = None
        skip_auto_headers = None
        skip_headers = None
        ssl        = True
        str_or_url = 'http://example.com'
        timeout    = <_SENTINEL.sentinel: 1>
        timer      = <aiohttp.helpers.TimerContext object at 0x7fa2e548c0e0>
        tm         = <aiohttp.helpers.TimeoutHandle object at 0x7fa2e5f4ca40>
        trace_request_ctx = None
        traces     = []
        url        = URL('http://example.com')
        version    = HttpVersion(major=1, minor=1)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <ClientResponse(http://example.com) [None None]>
None

connection = Connection<ConnectionKey(host='example.com', port=80, is_ssl=False, ssl=True, proxy=None, proxy_auth=None, proxy_headers_hash=None)>

    #x1B[0m#x1B[94masync#x1B[39;49;00m #x1B[94mdef#x1B[39;49;00m #x1B[92mstart#x1B[39;49;00m(#x1B[96mself#x1B[39;49;00m, connection: #x1B[33m"#x1B[39;49;00m#x1B[33mConnection#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m) -> #x1B[33m"#x1B[39;49;00m#x1B[33mClientResponse#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m:#x1B[90m#x1B[39;49;00m
    #x1B[90m    #x1B[39;49;00m#x1B[33m"""Start response processing."""#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
        #x1B[96mself#x1B[39;49;00m._closed = #x1B[94mFalse#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
        #x1B[96mself#x1B[39;49;00m._protocol = connection.protocol#x1B[90m#x1B[39;49;00m
        #x1B[96mself#x1B[39;49;00m._connection = connection#x1B[90m#x1B[39;49;00m
    #x1B[90m#x1B[39;49;00m
        #x1B[94mwith#x1B[39;49;00m #x1B[96mself#x1B[39;49;00m._timer:#x1B[90m#x1B[39;49;00m
            #x1B[94mwhile#x1B[39;49;00m #x1B[94mTrue#x1B[39;49;00m:#x1B[90m#x1B[39;49;00m
                #x1B[90m# read response#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
                #x1B[94mtry#x1B[39;49;00m:#x1B[90m#x1B[39;49;00m
                    protocol = #x1B[96mself#x1B[39;49;00m._protocol#x1B[90m#x1B[39;49;00m
                    message, payload = #x1B[94mawait#x1B[39;49;00m protocol.read()  #x1B[90m# type: ignore[union-attr]#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
                #x1B[94mexcept#x1B[39;49;00m http.HttpProcessingError #x1B[94mas#x1B[39;49;00m exc:#x1B[90m#x1B[39;49;00m
                    #x1B[94mraise#x1B[39;49;00m ClientResponseError(#x1B[90m#x1B[39;49;00m
                        #x1B[96mself#x1B[39;49;00m.request_info,#x1B[90m#x1B[39;49;00m
                        #x1B[96mself#x1B[39;49;00m.history,#x1B[90m#x1B[39;49;00m
                        status=exc.code,#x1B[90m#x1B[39;49;00m
                        message=exc.message,#x1B[90m#x1B[39;49;00m
                        headers=exc.headers,#x1B[90m#x1B[39;49;00m
                    ) #x1B[94mfrom#x1B[39;49;00m #x1B[04m#x1B[96mexc#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
    #x1B[90m#x1B[39;49;00m
                code = message.code#x1B[90m#x1B[39;49;00m
                #x1B[94mif#x1B[39;49;00m code < #x1B[94m100#x1B[39;49;00m #x1B[95mor#x1B[39;49;00m code > #x1B[94m199#x1B[39;49;00m #x1B[95mor#x1B[39;49;00m code == #x1B[94m101#x1B[39;49;00m:#x1B[90m#x1B[39;49;00m
                    #x1B[94mbreak#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
    #x1B[90m#x1B[39;49;00m
                #x1B[94mif#x1B[39;49;00m #x1B[96mself#x1B[39;49;00m._continue #x1B[95mis#x1B[39;49;00m #x1B[95mnot#x1B[39;49;00m #x1B[94mNone#x1B[39;49;00m:#x1B[90m#x1B[39;49;00m
                    set_result(#x1B[96mself#x1B[39;49;00m._continue, #x1B[94mTrue#x1B[39;49;00m)#x1B[90m#x1B[39;49;00m
                    #x1B[96mself#x1B[39;49;00m._continue = #x1B[94mNone#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
    #x1B[90m#x1B[39;49;00m
        #x1B[90m# payload eof handler#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
        payload.on_eof(#x1B[96mself#x1B[39;49;00m._response_eof)#x1B[90m#x1B[39;49;00m
    #x1B[90m#x1B[39;49;00m
        #x1B[90m# unpack message#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
>       #x1B[96mself#x1B[39;49;00m.version, #x1B[96mself#x1B[39;49;00m.status, #x1B[96mself#x1B[39;49;00m.reason, #x1B[96mself#x1B[39;49;00m._headers, #x1B[96mself#x1B[39;49;00m._raw_headers, *_ = (#x1B[90m#x1B[39;49;00m
            message#x1B[90m#x1B[39;49;00m
        )#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[31mE       ValueError: not enough values to unpack (expected at least 5, got 0)#x1B[0m

code       = 200
connection = Connection<ConnectionKey(host='example.com', port=80, is_ssl=False, ssl=True, proxy=None, proxy_auth=None, proxy_headers_hash=None)>
message    = <MagicMock spec_set='RawResponseMessage' id='140337607185488'>
payload    = <Mock id='140337607184624'>
protocol   = <NonCallableMagicMock spec='ResponseHandler' id='140337613580096'>
self       = <ClientResponse(http://example.com) [None None]>
None


#x1B[1m#x1B[31maiohttp/client_reqrep.py#x1B[0m:1007: ValueError

To view more test analytics, go to the Test Analytics Dashboard
Got feedback? Let us know on Github

@bdraco bdraco closed this Nov 24, 2024
@bdraco bdraco deleted the client_response_start branch November 24, 2024 19:49
@bdraco
Copy link
Member Author

bdraco commented Nov 24, 2024

Only makes a difference on the Py version. Cython version is already fast

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant