Skip to content

perf: remove heap allocation in parse_host #1021

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

Merged
merged 9 commits into from
Apr 30, 2025

Conversation

dsherret
Copy link
Contributor

@dsherret dsherret commented Feb 6, 2025

Before:

test long           ... bench:         302 ns/iter (+/- 42) = 142 MB/s

After:

test long           ... bench:         271 ns/iter (+/- 7) = 158 MB/s

Copy link

codecov bot commented Feb 6, 2025

Codecov Report

Attention: Patch coverage is 80.00000% with 12 lines in your changes missing coverage. Please review.

Please upload report for BASE (main@968e862). Learn more about missing BASE report.

Files with missing lines Patch % Lines
url/src/host.rs 80.95% 4 Missing ⚠️
url/src/parser.rs 77.77% 4 Missing ⚠️
idna/src/uts46.rs 70.00% 3 Missing ⚠️
url/src/lib.rs 75.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1021   +/-   ##
=======================================
  Coverage        ?   79.83%           
=======================================
  Files           ?       24           
  Lines           ?     4355           
  Branches        ?        0           
=======================================
  Hits            ?     3477           
  Misses          ?      878           
  Partials        ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dsherret dsherret marked this pull request as ready for review February 6, 2025 18:43
@@ -80,15 +79,34 @@ impl Host<String> {
///
/// <https://url.spec.whatwg.org/#host-parsing>
pub fn parse(input: &str) -> Result<Self, ParseError> {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't add, change, or remove from the public API, but please verify this as well in case I missed something.

@dsherret dsherret requested a review from lucacasonato February 7, 2025 15:24
/// and using Punycode as necessary.
///
/// This process may fail.
pub fn domain_to_ascii_from_cow(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hsivonen Please check if you find this new public API of idna to be acceptable.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gentle ping @hsivonen

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it's been several months, maybe this can be merged and then deprecated later if it's not the right approach?

Copy link
Collaborator

@lucacasonato lucacasonato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Considering the code looks good, the perf gain is meaningful, and no-one has objected to the new API surface in 3 months, I am going to land this now.

@lucacasonato lucacasonato enabled auto-merge April 30, 2025 15:57
@lucacasonato lucacasonato added this pull request to the merge queue Apr 30, 2025
Merged via the queue into servo:main with commit 7cff874 Apr 30, 2025
18 checks passed
@dsherret dsherret deleted the perf_heap_allocation_parse_host branch May 13, 2025 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants