asks icon indicating copy to clipboard operation
asks copied to clipboard

high CPU use for large HTTP response

Open belm0 opened this issue 6 years ago • 0 comments

My Trio app is making simple, periodic (persistent connection), non-SSL get requests for content of ~200K. I noticed high CPU use due to this request and confirmed with a sampling profiler.

I replaced use of asks with a bare-bones HTTP get implementation using Trio high-level networking and httptools for parsing. CPU use due to the HTTP requests decreased significantly (from about 11% to 3% of total app CPU), despite both implementations using Trio networking with a 10,000 byte receive size.

The profiler suggests that h11's next_event() adds significant overhead (4.3% of app total). The code of _catch_response proper is adding overhead as well (.9%). Generally the size of the call stack is alarming-- it goes on for pages.

screen shot 2019-02-25 at 2 32 34 pm

belm0 avatar Feb 25 '19 05:02 belm0