mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-03-31 17:55:36 +00:00
aquatic_http_protocol: urlencode/urldecode Request.key
About 11% performance regression for Request::from_bytes
This commit is contained in:
parent
0a0b57a9e8
commit
74a538963f
7 changed files with 1014 additions and 1007 deletions
7
Cargo.lock
generated
7
Cargo.lock
generated
|
|
@ -118,6 +118,7 @@ dependencies = [
|
||||||
"rand",
|
"rand",
|
||||||
"serde",
|
"serde",
|
||||||
"smartstring",
|
"smartstring",
|
||||||
|
"urlencoding",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -1835,6 +1836,12 @@ dependencies = [
|
||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "urlencoding"
|
||||||
|
version = "1.1.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c9232eb53352b4442e40d7900465dfc534e8cb2dc8f18656fcb2ac16112b5593"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "utf-8"
|
name = "utf-8"
|
||||||
version = "0.7.5"
|
version = "0.7.5"
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ memchr = "2"
|
||||||
rand = { version = "0.7", features = ["small_rng"] }
|
rand = { version = "0.7", features = ["small_rng"] }
|
||||||
serde = { version = "1", features = ["derive"] }
|
serde = { version = "1", features = ["derive"] }
|
||||||
smartstring = "0.2"
|
smartstring = "0.2"
|
||||||
|
urlencoding = "1"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
criterion = "0.3"
|
criterion = "0.3"
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ impl AnnounceRequest {
|
||||||
|
|
||||||
if let Some(ref key) = self.key {
|
if let Some(ref key) = self.key {
|
||||||
output.write_all(b"&key=")?;
|
output.write_all(b"&key=")?;
|
||||||
output.write_all(key.as_str().as_bytes())?;
|
output.write_all(::urlencoding::encode(key.as_str()).as_bytes())?;
|
||||||
}
|
}
|
||||||
|
|
||||||
output.write_all(b" HTTP/1.1\r\nConnection: keep-alive\r\n\r\n")?;
|
output.write_all(b" HTTP/1.1\r\nConnection: keep-alive\r\n\r\n")?;
|
||||||
|
|
@ -220,7 +220,7 @@ impl Request {
|
||||||
if value.len() > 100 {
|
if value.len() > 100 {
|
||||||
return Err(anyhow::anyhow!("'key' is too long"))
|
return Err(anyhow::anyhow!("'key' is too long"))
|
||||||
}
|
}
|
||||||
opt_key = Some(value.into());
|
opt_key = Some(::urlencoding::decode(value)?.into());
|
||||||
},
|
},
|
||||||
k => {
|
k => {
|
||||||
::log::info!("ignored unrecognized key: {}", k)
|
::log::info!("ignored unrecognized key: {}", k)
|
||||||
|
|
@ -360,8 +360,7 @@ mod tests {
|
||||||
fn quickcheck_serde_identity_request(){
|
fn quickcheck_serde_identity_request(){
|
||||||
fn prop(request: Request) -> TestResult {
|
fn prop(request: Request) -> TestResult {
|
||||||
if let Request::Announce(AnnounceRequest { key: Some(ref key), ..}) = request {
|
if let Request::Announce(AnnounceRequest { key: Some(ref key), ..}) = request {
|
||||||
if !key.is_ascii(){
|
if key.len() > 30 {
|
||||||
// Only ascii allowed in headers
|
|
||||||
return TestResult::discard();
|
return TestResult::discard();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
{"mean":{"confidence_interval":{"confidence_level":0.95,"lower_bound":712.3229147211995,"upper_bound":718.3354819324181},"point_estimate":715.2458821204962,"standard_error":1.533377033720048},"median":{"confidence_interval":{"confidence_level":0.95,"lower_bound":702.2487122668101,"upper_bound":705.6719507707569},"point_estimate":703.5000937701129,"standard_error":1.0124262081544313},"median_abs_dev":{"confidence_interval":{"confidence_level":0.95,"lower_bound":16.727369722981607,"upper_bound":20.093705443506796},"point_estimate":18.299859089063325,"standard_error":0.8424544581208894},"slope":{"confidence_interval":{"confidence_level":0.95,"lower_bound":712.837599394627,"upper_bound":719.6820952585409},"point_estimate":716.1242547212966,"standard_error":1.7426990107162317},"std_dev":{"confidence_interval":{"confidence_level":0.95,"lower_bound":40.92144156958538,"upper_bound":55.50547150845648},"point_estimate":48.25691972458682,"standard_error":3.7206560143491942}}
|
{"mean":{"confidence_interval":{"confidence_level":0.95,"lower_bound":791.6783637138329,"upper_bound":798.2060382161882},"point_estimate":794.7777653239414,"standard_error":1.670679553768017},"median":{"confidence_interval":{"confidence_level":0.95,"lower_bound":786.1377247215969,"upper_bound":789.3747173913043},"point_estimate":788.2154281612928,"standard_error":0.9080984924572599},"median_abs_dev":{"confidence_interval":{"confidence_level":0.95,"lower_bound":34.47577000388577,"upper_bound":38.99231743541378},"point_estimate":37.25560574108035,"standard_error":1.1689453074940308},"slope":{"confidence_interval":{"confidence_level":0.95,"lower_bound":791.1964524096214,"upper_bound":798.189227060581},"point_estimate":794.5503586699593,"standard_error":1.785366051793957},"std_dev":{"confidence_interval":{"confidence_level":0.95,"lower_bound":41.22148757811178,"upper_bound":64.85026519223337},"point_estimate":52.942361554527636,"standard_error":6.055601310575156}}
|
||||||
File diff suppressed because it is too large
Load diff
File diff suppressed because one or more lines are too long
|
|
@ -1 +1 @@
|
||||||
[616.2953956893135,654.5607433380189,756.6016704012334,794.8670180499388]
|
[635.6000013134935,698.449239826088,866.0472091930068,928.8964477056013]
|
||||||
Loading…
Add table
Add a link
Reference in a new issue