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:
|
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).
Version
hyper-1.1.0Platform
Linux x86_64
Description
I was looking at the memory allocation patterns of a
hyper-1.0HTTP1 server with afastwebsocketendpoint (basically equivalent to this example) and I noticed that there is a spurious memory copy-allocation in theuri.parse()?URI parsing logic here:hyper/src/proto/h1/role.rs
Lines 157 to 168 in 00a703a
This is visible in memory profiles as a
Bytes::copy_from_slice()coming from aUri::from_str():I suspect this is the root-cause of some performance impact that has been noticed in the CPU profiles at #3258 (comment).