perf: speed up url::get_href for common special URLs - #1200
Conversation
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.
Codecov Report❌ Patch coverage is
❌ 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. 🚀 New features to boost your workflow:
|
Merging this PR will degrade performance by 3.06%
|
| 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)
Footnotes
-
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. ↩
There was a problem hiding this comment.
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::stringwithout value-initializing new bytes when a supported library API exists. - Optimizes the
get_href()fast path by hard-codinghttp/httpsscheme 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.
|
Closing: CodSpeed reports a −3.06% regression on On Linux/libstdc++ the uninitialized-resize path often falls back to The larger wins for that bench already land via:
No further work planned on this branch. |
Summary
Speed up
ada::url::get_href()when the URL is special, has a host, and has no credentials or port:resize_and_overwrite/ Apple__resize_default_init/ fallbackresize)https/httpscheme prefixes to avoid special-scheme table loadsScope
include/ada/url-inl.honlyIndependence
Targets
mainonly. Independent of the simple-absolute and href-cache PRs; can land in any order (not stacked).Test plan
AdaURL_href