-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
A-http1Area: HTTP/1 specific.Area: HTTP/1 specific.C-performanceCategory: performance. This is making existing behavior go faster.Category: performance. This is making existing behavior go faster.E-easyEffort: easy. A task that would be a great starting point for a new contributor.Effort: easy. A task that would be a great starting point for a new contributor.
Description
Version
hyper-1.1.0
Platform
Linux x86_64
Description
I was looking at the memory allocation patterns of a hyper-1.0 HTTP1 server with a fastwebsocket endpoint (basically equivalent to this example) and I noticed that there is a spurious memory copy-allocation in the uri.parse()? URI parsing logic here:
Lines 157 to 168 in 00a703a
| match req.parse_with_uninit_headers(bytes, &mut headers) { | |
| Ok(httparse::Status::Complete(parsed_len)) => { | |
| trace!("Request.parse Complete({})", parsed_len); | |
| len = parsed_len; | |
| let uri = req.path.unwrap(); | |
| if uri.len() > MAX_URI_LEN { | |
| return Err(Parse::UriTooLong); | |
| } | |
| subject = RequestLine( | |
| Method::from_bytes(req.method.unwrap().as_bytes())?, | |
| uri.parse()?, | |
| ); |
This is visible in memory profiles as a Bytes::copy_from_slice() coming from a Uri::from_str():
I suspect this is the root-cause of some performance impact that has been noticed in the CPU profiles at #3258 (comment).
Metadata
Metadata
Assignees
Labels
A-http1Area: HTTP/1 specific.Area: HTTP/1 specific.C-performanceCategory: performance. This is making existing behavior go faster.Category: performance. This is making existing behavior go faster.E-easyEffort: easy. A task that would be a great starting point for a new contributor.Effort: easy. A task that would be a great starting point for a new contributor.
