diff --git a/Cargo.toml b/Cargo.toml index afebfc486..9f0748e0c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -125,7 +125,3 @@ harness = false [[bench]] name = "service" harness = false - -[[bench]] -name = "cloneable" -harness = false diff --git a/actix-http/src/cloneable.rs b/actix-http/src/cloneable.rs index c1dbfa430..b64c299fc 100644 --- a/actix-http/src/cloneable.rs +++ b/actix-http/src/cloneable.rs @@ -6,7 +6,7 @@ use actix_service::Service; #[doc(hidden)] /// Service that allows to turn non-clone service to a service with `Clone` impl -/// +/// /// # Panics /// CloneableService might panic with some creative use of thread local storage. /// See https://github.com/actix/actix-web/issues/1295 for example diff --git a/actix-http/src/cookie/draft.rs b/actix-http/src/cookie/draft.rs index 1c7123422..a6525a605 100644 --- a/actix-http/src/cookie/draft.rs +++ b/actix-http/src/cookie/draft.rs @@ -14,13 +14,13 @@ use std::fmt; /// normal. In some browsers, this will implicitly handle the cookie as if "Lax" /// and in others, "None". It's best to explicitly set the `SameSite` attribute /// to avoid inconsistent behavior. -/// +/// /// **Note:** Depending on browser, the `Secure` attribute may be required for /// `SameSite` "None" cookies to be accepted. /// /// **Note:** This cookie attribute is an HTTP draft! Its meaning and definition /// are subject to change. -/// +/// /// More info about these draft changes can be found in the draft spec: /// - https://tools.ietf.org/html/draft-west-cookie-incrementalism-00 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] diff --git a/benches/cloneable.rs b/benches/cloneable.rs deleted file mode 100644 index 31993eeaf..000000000 --- a/benches/cloneable.rs +++ /dev/null @@ -1,37 +0,0 @@ -mod experiments; -mod service; - -use actix_web::test::ok_service; -use criterion::{criterion_main, Criterion}; -use experiments::cloneable::cloneable; -use experiments::cloneable::cloneable_safe; -use service::bench_async_service; - -// This is benchmark of effect by replacing UnsafeCell to RefCell in CloneableService -// Issue: https://github.com/actix/actix-web/issues/1295 -// -// Note: numbers may vary from run to run +-20%, probably due to async env -// async_service_direct time: [1.0076 us 1.0300 us 1.0507 us] -// change: [-32.491% -23.295% -15.790%] (p = 0.00 < 0.05) -// async_service_cloneable_unsafe -// time: [1.0857 us 1.1208 us 1.1629 us] -// change: [-2.9318% +5.7660% +15.004%] (p = 0.27 > 0.05) -// async_service_cloneable_safe -// time: [1.0703 us 1.1002 us 1.1390 us] -// change: [-9.2951% -1.1186% +6.5384%] (p = 0.80 > 0.05) - -pub fn service_benches() { - let mut criterion: Criterion<_> = Criterion::default().configure_from_args(); - bench_async_service(&mut criterion, ok_service(), "async_service_direct"); - bench_async_service( - &mut criterion, - cloneable::CloneableService::new(ok_service()), - "async_service_cloneable_unsafe", - ); - bench_async_service( - &mut criterion, - cloneable_safe::CloneableService::new(ok_service()), - "async_service_cloneable_safe", - ); -} -criterion_main!(service_benches); diff --git a/benches/experiments/cloneable/cloneable.rs b/benches/experiments/cloneable/cloneable.rs deleted file mode 100644 index 65c6bec21..000000000 --- a/benches/experiments/cloneable/cloneable.rs +++ /dev/null @@ -1,36 +0,0 @@ -use std::cell::UnsafeCell; -use std::rc::Rc; -use std::task::{Context, Poll}; - -use actix_service::Service; - -#[doc(hidden)] -/// Service that allows to turn non-clone service to a service with `Clone` impl -pub(crate) struct CloneableService(Rc>); - -impl CloneableService { - pub(crate) fn new(service: T) -> Self { - Self(Rc::new(UnsafeCell::new(service))) - } -} - -impl Clone for CloneableService { - fn clone(&self) -> Self { - Self(self.0.clone()) - } -} - -impl Service for CloneableService { - type Request = T::Request; - type Response = T::Response; - type Error = T::Error; - type Future = T::Future; - - fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { - unsafe { &mut *self.0.as_ref().get() }.poll_ready(cx) - } - - fn call(&mut self, req: T::Request) -> Self::Future { - unsafe { &mut *self.0.as_ref().get() }.call(req) - } -} diff --git a/benches/experiments/cloneable/cloneable_safe.rs b/benches/experiments/cloneable/cloneable_safe.rs deleted file mode 100644 index 0540b59cd..000000000 --- a/benches/experiments/cloneable/cloneable_safe.rs +++ /dev/null @@ -1,36 +0,0 @@ -use std::cell::RefCell; -use std::rc::Rc; -use std::task::{Context, Poll}; - -use actix_service::Service; - -#[doc(hidden)] -/// Service that allows to turn non-clone service to a service with `Clone` impl -pub(crate) struct CloneableService(Rc>); - -impl CloneableService { - pub(crate) fn new(service: T) -> Self { - Self(Rc::new(RefCell::new(service))) - } -} - -impl Clone for CloneableService { - fn clone(&self) -> Self { - Self(self.0.clone()) - } -} - -impl Service for CloneableService { - type Request = T::Request; - type Response = T::Response; - type Error = T::Error; - type Future = T::Future; - - fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { - self.0.borrow_mut().poll_ready(cx) - } - - fn call(&mut self, req: T::Request) -> Self::Future { - self.0.borrow_mut().call(req) - } -} diff --git a/benches/experiments/cloneable/mod.rs b/benches/experiments/cloneable/mod.rs deleted file mode 100644 index 531b034c7..000000000 --- a/benches/experiments/cloneable/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod cloneable; -pub mod cloneable_safe; diff --git a/benches/experiments/mod.rs b/benches/experiments/mod.rs deleted file mode 100644 index a239c5498..000000000 --- a/benches/experiments/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod cloneable;