Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: remove unnecessary allocation when writing http dates #3261

Merged
merged 5 commits into from
Feb 7, 2024

Conversation

robjtede
Copy link
Member

@robjtede robjtede commented Jan 24, 2024

PR Type

Perf

PR Checklist

  • Tests for the changes have been added / updated.
  • Documentation comments have been added / updated.
  • A changelog entry has been made for the appropriate packages.
  • Format code with the latest stable rustfmt.
  • (Team) Label with affected crates and semver status.

Overview

Removes unnecessary allocation when formatting HTTP Dates.

Results from divan benchmark

Before:

Timer precision: 41 ns
date_formatting     fastest       │ slowest       │ median        │ mean          │ samples │ iters
╰─ date_formatting  94.87 ns      │ 107.6 ns      │ 95.29 ns      │ 95.79 ns      │ 100     │ 100000
                    alloc:        │               │               │               │         │
                      2           │ 0             │ 2             │ 1.98          │         │
                      58 B        │ 0 B           │ 58 B          │ 57.42 B       │         │
                    dealloc:      │               │               │               │         │
                      2           │ 0             │ 2             │ 1.98          │         │
                      58 B        │ 0 B           │ 58 B          │ 57.42 B       │         │

After:

Timer precision: 41 ns
date_formatting     fastest       │ slowest       │ median        │ mean          │ samples │ iters
╰─ date_formatting  77.34 ns      │ 127.9 ns      │ 80.63 ns      │ 83.82 ns      │ 100     │ 100000
                    alloc:        │               │               │               │         │
                      1           │ 1             │ 1             │ 0.99          │         │
                      29 B        │ 29 B          │ 29 B          │ 28.71 B       │         │
                    dealloc:      │               │               │               │         │
                      1           │ 1             │ 1             │ 0.99          │         │
                      29 B        │ 29 B          │ 29 B          │ 28.71 B       │         │

@robjtede robjtede added A-http project: actix-http B-semver-norelease change that does not require a release labels Jan 24, 2024
@robjtede robjtede added this to the actix-web v4.4 milestone Jan 24, 2024
@robjtede robjtede force-pushed the perf-httpdate branch 2 times, most recently from 4607830 to 29a8331 Compare January 24, 2024 09:04
@robjtede robjtede removed this from the actix-web v4.4 milestone Feb 4, 2024
@robjtede robjtede merged commit 1e2ef6f into master Feb 7, 2024
13 checks passed
@robjtede robjtede deleted the perf-httpdate branch February 7, 2024 03:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-http project: actix-http B-semver-norelease change that does not require a release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant