Skip to content

Commit 1e2ef6f

Browse files
authored
perf: remove unnecessary allocation when writing http dates (#3261)
1 parent 7e4e12b commit 1e2ef6f

File tree

29 files changed

+75
-61
lines changed

29 files changed

+75
-61
lines changed

.github/workflows/ci.yml

+5-9
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
- { name: macOS, os: macos-latest, triple: x86_64-apple-darwin }
2727
- { name: Windows, os: windows-latest, triple: x86_64-pc-windows-msvc }
2828
version:
29-
- { name: msrv, version: 1.68.0 }
29+
- { name: msrv, version: 1.70.0 }
3030
- { name: stable, version: stable }
3131

3232
name: ${{ matrix.target.name }} / ${{ matrix.version.name }}
@@ -54,14 +54,10 @@ jobs:
5454
with:
5555
tool: cargo-hack,cargo-ci-cache-clean
5656

57-
- name: workaround MSRV issues
58-
if: matrix.version.name == 'msrv'
59-
run: |
60-
cargo update -p=ciborium --precise=0.2.1
61-
cargo update -p=ciborium-ll --precise=0.2.1
62-
cargo update -p=clap --precise=4.3.24
63-
cargo update -p=clap_lex --precise=0.5.0
64-
cargo update -p=anstyle --precise=1.0.2
57+
# - name: workaround MSRV issues
58+
# if: matrix.version.name == 'msrv'
59+
# run: |
60+
# cargo update -p=anstyle --precise=1.0.2
6561

6662
- name: check minimal
6763
run: cargo ci-check-min

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ members = [
1717
[workspace.package]
1818
license = "MIT OR Apache-2.0"
1919
edition = "2021"
20-
rust-version = "1.68"
20+
rust-version = "1.70"
2121

2222
[profile.dev]
2323
# Disabling debug info speeds up builds a bunch and we don't rely on it for debugging that much.

actix-files/CHANGES.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased
44

5+
- Minimum supported Rust version (MSRV) is now 1.70.
6+
57
## 0.6.5
68

79
- Fix handling of special characters in filenames.

actix-files/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
[![crates.io](https://img.shields.io/crates/v/actix-files?label=latest)](https://crates.io/crates/actix-files)
66
[![Documentation](https://docs.rs/actix-files/badge.svg?version=0.6.5)](https://docs.rs/actix-files/0.6.5)
7-
![Version](https://img.shields.io/badge/rustc-1.68+-ab6000.svg)
7+
![Version](https://img.shields.io/badge/rustc-1.70+-ab6000.svg)
88
![License](https://img.shields.io/crates/l/actix-files.svg)
99
<br />
1010
[![dependency status](https://deps.rs/crate/actix-files/0.6.5/status.svg)](https://deps.rs/crate/actix-files/0.6.5)

actix-http-test/CHANGES.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased
44

5+
- Minimum supported Rust version (MSRV) is now 1.70.
6+
57
## 3.2.0
68

79
- Minimum supported Rust version (MSRV) is now 1.68 due to transitive `time` dependency.

actix-http-test/README.md

+1-6
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,11 @@
66

77
[![crates.io](https://img.shields.io/crates/v/actix-http-test?label=latest)](https://crates.io/crates/actix-http-test)
88
[![Documentation](https://docs.rs/actix-http-test/badge.svg?version=3.2.0)](https://docs.rs/actix-http-test/3.2.0)
9-
![Version](https://img.shields.io/badge/rustc-1.68+-ab6000.svg)
9+
![Version](https://img.shields.io/badge/rustc-1.70+-ab6000.svg)
1010
![MIT or Apache 2.0 licensed](https://img.shields.io/crates/l/actix-http-test)
1111
<br>
1212
[![Dependency Status](https://deps.rs/crate/actix-http-test/3.2.0/status.svg)](https://deps.rs/crate/actix-http-test/3.2.0)
1313
[![Download](https://img.shields.io/crates/d/actix-http-test.svg)](https://crates.io/crates/actix-http-test)
1414
[![Chat on Discord](https://img.shields.io/discord/771444961383153695?label=chat&logo=discord)](https://discord.gg/NWpN5mmg3x)
1515

1616
<!-- prettier-ignore-end -->
17-
18-
## Documentation & Resources
19-
20-
- [API Documentation](https://docs.rs/actix-http-test)
21-
- Minimum Supported Rust Version (MSRV): 1.68

actix-http/CHANGES.md

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Unreleased
44

5+
### Changed
6+
7+
- Minimum supported Rust version (MSRV) is now 1.70.
8+
59
## 3.6.0
610

711
### Added

actix-http/Cargo.toml

+5
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ actix-web = "4"
126126

127127
async-stream = "0.3"
128128
criterion = { version = "0.5", features = ["html_reports"] }
129+
divan = "0.1.8"
129130
env_logger = "0.10"
130131
futures-util = { version = "0.3.17", default-features = false, features = ["alloc"] }
131132
memchr = "2.4"
@@ -153,3 +154,7 @@ required-features = ["http2", "rustls-0_22"]
153154
name = "response-body-compression"
154155
harness = false
155156
required-features = ["compress-brotli", "compress-gzip", "compress-zstd"]
157+
158+
[[bench]]
159+
name = "date-formatting"
160+
harness = false

actix-http/README.md

+1-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
[![crates.io](https://img.shields.io/crates/v/actix-http?label=latest)](https://crates.io/crates/actix-http)
88
[![Documentation](https://docs.rs/actix-http/badge.svg?version=3.6.0)](https://docs.rs/actix-http/3.6.0)
9-
![Version](https://img.shields.io/badge/rustc-1.68+-ab6000.svg)
9+
![Version](https://img.shields.io/badge/rustc-1.70+-ab6000.svg)
1010
![MIT or Apache 2.0 licensed](https://img.shields.io/crates/l/actix-http.svg)
1111
<br />
1212
[![dependency status](https://deps.rs/crate/actix-http/3.6.0/status.svg)](https://deps.rs/crate/actix-http/3.6.0)
@@ -15,11 +15,6 @@
1515

1616
<!-- prettier-ignore-end -->
1717

18-
## Documentation & Resources
19-
20-
- [API Documentation](https://docs.rs/actix-http)
21-
- Minimum Supported Rust Version (MSRV): 1.68
22-
2318
## Examples
2419

2520
```rust

actix-http/benches/date-formatting.rs

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
use std::time::SystemTime;
2+
3+
use actix_http::header::HttpDate;
4+
use divan::{black_box, AllocProfiler, Bencher};
5+
6+
#[global_allocator]
7+
static ALLOC: AllocProfiler = AllocProfiler::system();
8+
9+
#[divan::bench]
10+
fn date_formatting(b: Bencher<'_, '_>) {
11+
let now = SystemTime::now();
12+
13+
b.bench(|| {
14+
black_box(HttpDate::from(black_box(now)).to_string());
15+
})
16+
}
17+
18+
fn main() {
19+
divan::main();
20+
}

actix-http/src/date.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ impl Date {
2828

2929
fn update(&mut self) {
3030
self.pos = 0;
31-
write!(self, "{}", httpdate::fmt_http_date(SystemTime::now())).unwrap();
31+
write!(self, "{}", httpdate::HttpDate::from(SystemTime::now())).unwrap();
3232
}
3333
}
3434

actix-http/src/header/shared/http_date.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ impl FromStr for HttpDate {
2424

2525
impl fmt::Display for HttpDate {
2626
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
27-
let date_str = httpdate::fmt_http_date(self.0);
28-
f.write_str(&date_str)
27+
httpdate::HttpDate::from(self.0).fmt(f)
2928
}
3029
}
3130

@@ -37,7 +36,7 @@ impl TryIntoHeaderValue for HttpDate {
3736
let mut wrt = MutWriter(&mut buf);
3837

3938
// unwrap: date output is known to be well formed and of known length
40-
write!(wrt, "{}", httpdate::fmt_http_date(self.0)).unwrap();
39+
write!(wrt, "{}", self).unwrap();
4140

4241
HeaderValue::from_maybe_shared(buf.split().freeze())
4342
}

actix-multipart-derive/CHANGES.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased
44

5+
- Minimum supported Rust version (MSRV) is now 1.70.
6+
57
## 0.6.1
68

79
- Update `syn` dependency to `2`.

actix-multipart-derive/README.md

+1-6
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,11 @@
66

77
[![crates.io](https://img.shields.io/crates/v/actix-multipart-derive?label=latest)](https://crates.io/crates/actix-multipart-derive)
88
[![Documentation](https://docs.rs/actix-multipart-derive/badge.svg?version=0.6.1)](https://docs.rs/actix-multipart-derive/0.6.1)
9-
![Version](https://img.shields.io/badge/rustc-1.68+-ab6000.svg)
9+
![Version](https://img.shields.io/badge/rustc-1.70+-ab6000.svg)
1010
![MIT or Apache 2.0 licensed](https://img.shields.io/crates/l/actix-multipart-derive.svg)
1111
<br />
1212
[![dependency status](https://deps.rs/crate/actix-multipart-derive/0.6.1/status.svg)](https://deps.rs/crate/actix-multipart-derive/0.6.1)
1313
[![Download](https://img.shields.io/crates/d/actix-multipart-derive.svg)](https://crates.io/crates/actix-multipart-derive)
1414
[![Chat on Discord](https://img.shields.io/discord/771444961383153695?label=chat&logo=discord)](https://discord.gg/NWpN5mmg3x)
1515

1616
<!-- prettier-ignore-end -->
17-
18-
## Documentation & Resources
19-
20-
- [API Documentation](https://docs.rs/actix-multipart-derive)
21-
- Minimum Supported Rust Version (MSRV): 1.68

actix-multipart-derive/tests/trybuild.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#[rustversion::stable(1.68)] // MSRV
1+
#[rustversion::stable(1.70)] // MSRV
22
#[test]
33
fn compile_macros() {
44
let t = trybuild::TestCases::new();

actix-multipart/CHANGES.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased
44

5+
- Minimum supported Rust version (MSRV) is now 1.70.
6+
57
## 0.6.1
68

79
- Minimum supported Rust version (MSRV) is now 1.68 due to transitive `time` dependency.

actix-multipart/README.md

+1-6
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,11 @@
66

77
[![crates.io](https://img.shields.io/crates/v/actix-multipart?label=latest)](https://crates.io/crates/actix-multipart)
88
[![Documentation](https://docs.rs/actix-multipart/badge.svg?version=0.6.1)](https://docs.rs/actix-multipart/0.6.1)
9-
![Version](https://img.shields.io/badge/rustc-1.68+-ab6000.svg)
9+
![Version](https://img.shields.io/badge/rustc-1.70+-ab6000.svg)
1010
![MIT or Apache 2.0 licensed](https://img.shields.io/crates/l/actix-multipart.svg)
1111
<br />
1212
[![dependency status](https://deps.rs/crate/actix-multipart/0.6.1/status.svg)](https://deps.rs/crate/actix-multipart/0.6.1)
1313
[![Download](https://img.shields.io/crates/d/actix-multipart.svg)](https://crates.io/crates/actix-multipart)
1414
[![Chat on Discord](https://img.shields.io/discord/771444961383153695?label=chat&logo=discord)](https://discord.gg/NWpN5mmg3x)
1515

1616
<!-- prettier-ignore-end -->
17-
18-
## Documentation & Resources
19-
20-
- [API Documentation](https://docs.rs/actix-multipart)
21-
- Minimum Supported Rust Version (MSRV): 1.68

actix-router/CHANGES.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased
44

5+
- Minimum supported Rust version (MSRV) is now 1.70.
6+
57
## 0.5.2
68

79
- Minimum supported Rust version (MSRV) is now 1.68 due to transitive `time` dependency.

actix-router/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
[![crates.io](https://img.shields.io/crates/v/actix-router?label=latest)](https://crates.io/crates/actix-router)
66
[![Documentation](https://docs.rs/actix-router/badge.svg?version=0.5.2)](https://docs.rs/actix-router/0.5.2)
7-
![Version](https://img.shields.io/badge/rustc-1.68+-ab6000.svg)
7+
![Version](https://img.shields.io/badge/rustc-1.70+-ab6000.svg)
88
![MIT or Apache 2.0 licensed](https://img.shields.io/crates/l/actix-router.svg)
99
<br />
1010
[![dependency status](https://deps.rs/crate/actix-router/0.5.2/status.svg)](https://deps.rs/crate/actix-router/0.5.2)

actix-test/CHANGES.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased
44

5+
- Minimum supported Rust version (MSRV) is now 1.70.
6+
57
## 0.1.3
68

79
- Add `TestServerConfig::rustls_0_22()` method for Rustls v0.22 support behind new `rustls-0_22` crate feature.

actix-web-actors/CHANGES.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased
44

5+
- Minimum supported Rust version (MSRV) is now 1.70.
6+
57
## 4.3.0
68

79
- Minimum supported Rust version (MSRV) is now 1.68 due to transitive `time` dependency.

actix-web-actors/README.md

+1-6
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,11 @@
66

77
[![crates.io](https://img.shields.io/crates/v/actix-web-actors?label=latest)](https://crates.io/crates/actix-web-actors)
88
[![Documentation](https://docs.rs/actix-web-actors/badge.svg?version=4.3.0)](https://docs.rs/actix-web-actors/4.3.0)
9-
![Version](https://img.shields.io/badge/rustc-1.68+-ab6000.svg)
9+
![Version](https://img.shields.io/badge/rustc-1.70+-ab6000.svg)
1010
![License](https://img.shields.io/crates/l/actix-web-actors.svg)
1111
<br />
1212
[![dependency status](https://deps.rs/crate/actix-web-actors/4.3.0/status.svg)](https://deps.rs/crate/actix-web-actors/4.3.0)
1313
[![Download](https://img.shields.io/crates/d/actix-web-actors.svg)](https://crates.io/crates/actix-web-actors)
1414
[![Chat on Discord](https://img.shields.io/discord/771444961383153695?label=chat&logo=discord)](https://discord.gg/NWpN5mmg3x)
1515

1616
<!-- prettier-ignore-end -->
17-
18-
## Documentation & Resources
19-
20-
- [API Documentation](https://docs.rs/actix-web-actors)
21-
- Minimum Supported Rust Version (MSRV): 1.68

actix-web-codegen/CHANGES.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased
44

5+
- Minimum supported Rust version (MSRV) is now 1.70.
6+
57
## 4.2.2
68

79
- Fix regression when declaring `wrap` attribute using an expression.

actix-web-codegen/README.md

+1-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
[![crates.io](https://img.shields.io/crates/v/actix-web-codegen?label=latest)](https://crates.io/crates/actix-web-codegen)
88
[![Documentation](https://docs.rs/actix-web-codegen/badge.svg?version=4.2.2)](https://docs.rs/actix-web-codegen/4.2.2)
9-
![Version](https://img.shields.io/badge/rustc-1.68+-ab6000.svg)
9+
![Version](https://img.shields.io/badge/rustc-1.70+-ab6000.svg)
1010
![License](https://img.shields.io/crates/l/actix-web-codegen.svg)
1111
<br />
1212
[![dependency status](https://deps.rs/crate/actix-web-codegen/4.2.2/status.svg)](https://deps.rs/crate/actix-web-codegen/4.2.2)
@@ -15,11 +15,6 @@
1515

1616
<!-- prettier-ignore-end -->
1717

18-
## Documentation & Resources
19-
20-
- [API Documentation](https://docs.rs/actix-web-codegen)
21-
- Minimum Supported Rust Version (MSRV): 1.68
22-
2318
## Compile Testing
2419

2520
Uses the [`trybuild`] crate. All compile fail tests should include a stderr file generated by `trybuild`. See the [workflow section](https://github.com/dtolnay/trybuild#workflow) of the trybuild docs for info on how to do this.

actix-web-codegen/tests/trybuild.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#[rustversion::stable(1.68)] // MSRV
1+
#[rustversion::stable(1.70)] // MSRV
22
#[test]
33
fn compile_macros() {
44
let t = trybuild::TestCases::new();

actix-web/CHANGES.md

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Unreleased
44

5+
### Changed
6+
7+
- Minimum supported Rust version (MSRV) is now 1.70.
8+
59
## 4.5.1
610

711
### Fixed

actix-web/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
[![crates.io](https://img.shields.io/crates/v/actix-web?label=latest)](https://crates.io/crates/actix-web)
1111
[![Documentation](https://docs.rs/actix-web/badge.svg?version=4.5.1)](https://docs.rs/actix-web/4.5.1)
12-
![MSRV](https://img.shields.io/badge/rustc-1.68+-ab6000.svg)
12+
![MSRV](https://img.shields.io/badge/rustc-1.70+-ab6000.svg)
1313
![MIT or Apache 2.0 licensed](https://img.shields.io/crates/l/actix-web.svg)
1414
[![Dependency Status](https://deps.rs/crate/actix-web/4.5.1/status.svg)](https://deps.rs/crate/actix-web/4.5.1)
1515
<br />
@@ -37,7 +37,7 @@
3737
- SSL support using OpenSSL or Rustls
3838
- Middlewares ([Logger, Session, CORS, etc](https://actix.rs/docs/middleware/))
3939
- Integrates with the [`awc` HTTP client](https://docs.rs/awc/)
40-
- Runs on stable Rust 1.68+
40+
- Runs on stable Rust 1.70+
4141

4242
## Documentation
4343

awc/CHANGES.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased
44

5+
- Minimum supported Rust version (MSRV) is now 1.70.
6+
57
## 3.4.0
68

79
- Add `rustls-0_22-webpki-roots` and `rustls-0_22-native-roots` crate feature.

awc/README.md

+3-5
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,11 @@
1212

1313
<!-- prettier-ignore-end -->
1414

15-
## Documentation & Resources
15+
## Examples
1616

17-
- [API Documentation](https://docs.rs/awc)
18-
- [Example Project](https://github.com/actix/examples/tree/master/https-tls/awc-https)
19-
- Minimum Supported Rust Version (MSRV): 1.68
17+
[Example project using TLS-enabled client →](https://github.com/actix/examples/tree/master/https-tls/awc-https)
2018

21-
## Example
19+
Basic usage:
2220

2321
```rust
2422
use actix_rt::System;

0 commit comments

Comments
 (0)