Skip to content

perf: speed up url::get_href for common special URLs - #1200

Closed
anonrig wants to merge 1 commit into
mainfrom
perf/url-get-href-hot-path
Closed

perf: speed up url::get_href for common special URLs#1200
anonrig wants to merge 1 commit into
mainfrom
perf/url-get-href-hot-path

Conversation

@anonrig

@anonrig anonrig commented Jul 31, 2026

Copy link
Copy Markdown
Member

Summary

Speed up ada::url::get_href() when the URL is special, has a host, and has no credentials or port:

  • Prefer uninitialized string resize (resize_and_overwrite / Apple __resize_default_init / fallback resize)
  • Hard-code https / http scheme prefixes to avoid special-scheme table loads

Scope

  • include/ada/url-inl.h only
  • No parser changes

Independence

Targets main only. Independent of the simple-absolute and href-cache PRs; can land in any order (not stacked).

Test plan

  • Full CI
  • Optional: local Release microbench on AdaURL_href

Use uninitialized string resize when available and hard-code the https/http
scheme prefixes on the no-credentials, no-port hot path to cut table loads
and zero-init overhead when materializing href.
Copilot AI review requested due to automatic review settings July 31, 2026 17:03
@codecov

codecov Bot commented Jul 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 71.05263% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 61.09%. Comparing base (d154358) to head (9477a92).

Files with missing lines Patch % Lines
include/ada/url-inl.h 71.05% 0 Missing and 11 partials ⚠️

❌ Your patch check has failed because the patch coverage (71.05%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1200      +/-   ##
==========================================
+ Coverage   61.06%   61.09%   +0.03%     
==========================================
  Files          38       38              
  Lines        6939     6950      +11     
  Branches     3231     3233       +2     
==========================================
+ Hits         4237     4246       +9     
  Misses        749      749              
- Partials     1953     1955       +2     

☔ View full report in Codecov by Harness.
📢 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.

@codspeed-hq

codspeed-hq Bot commented Jul 31, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 3.06%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

❌ 1 regressed benchmark
✅ 28 untouched benchmarks
⏩ 4 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
BenchData_BasicBench_AdaURL_href 98.1 ms 101.2 ms -3.06%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing perf/url-get-href-hot-path (9477a92) with main (d154358)

Open in CodSpeed

Footnotes

  1. 4 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR optimizes ada::url::get_href() for the common case of “special” absolute URLs that have a host and do not include credentials or an explicit port, reducing work in the hot path.

Changes:

  • Adds a small internal helper to resize std::string without value-initializing new bytes when a supported library API exists.
  • Optimizes the get_href() fast path by hard-coding http/https scheme prefixes and constructing the output via direct writes into a pre-sized buffer.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@anonrig

anonrig commented Jul 31, 2026

Copy link
Copy Markdown
Member Author

Closing: CodSpeed reports a −3.06% regression on BenchData_BasicBench_AdaURL_href (98.1 → 101.2 ms) vs main.

On Linux/libstdc++ the uninitialized-resize path often falls back to resize (same zero-init as before) while adding scheme-branch overhead, so this change is net-negative in Simulation and is not worth landing.

The larger wins for that bench already land via:

No further work planned on this branch.

@anonrig anonrig closed this Jul 31, 2026
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