Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Use stackalloc char&byte arrays for decoding Url values in HttpUtiliy.ParseQueryString#102745

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
MihaZupan merged 3 commits intodotnet:mainfromTrayanZapryanov:optimize_url_decoder
May 29, 2024

Conversation

TrayanZapryanov
Copy link
Contributor

  1. Convert UrlDecoder to ref struct
  2. If Url is less than 256 characters, do no allocate char&byte arrays
  3. Replace substring operation with Span

@ghostghost added the area-System.Net labelMay 28, 2024
@dotnet-policy-servicedotnet-policy-servicebot added the community-contributionIndicates that the PR has been added by a community member labelMay 28, 2024
@dotnet-policy-serviceDotnet Policy Service
Copy link
Contributor

Tagging subscribers to this area: @dotnet/ncl
See info inarea-owners.md if you want to be subscribed.

@TrayanZapryanov
Copy link
ContributorAuthor

TrayanZapryanov commentedMay 28, 2024
edited
Loading

Benchmark:

[MemoryDiagnoser]publicclassHttpUtilityBenchmarks{privatestaticstringUnicodeStr=>newstring(new[]{'\u304a','\u75b2','\u308c','\u69d8','\u3067','\u3059'});privatestaticstringEncodedUnicodeStr=>HttpUtility.UrlEncode(UnicodeStr)+"="+HttpUtility.UrlEncode(UnicodeStr);[Benchmark(Baseline=true)]publicNameValueCollectionParseQueryString()=>HttpUtility.ParseQueryString("https://portal.azure.com/#@testgroup.onmicrosoft.com/dashboard/arm/subscriptions/111111-abac-4067-81ba-5ae054d891b5/"+"resourcegroups/dashboards/providers/microsoft.portal/dashboards/3456268-8630-60f7-aaac-eca38aca231");[Benchmark]publicNameValueCollectionParseQueryString_Mix()=>HttpUtility.ParseQueryString("ReturnUrl=http%3a%2f%2flocalhost%2flogin%2fauthenticate%3fReturnUrl%3dhttp%3a%2f%2flocalhost%2fsecured_area%26__provider__%3dgoogle");[Benchmark]publicNameValueCollectionParseQueryString_Unicode()=>HttpUtility.ParseQueryString(EncodedUnicodeStr);}

Results:
Machine:
BenchmarkDotNet v0.13.12, Windows 11 (10.0.22631.3593/23H2/2023Update/SunValley3)
11th Gen Intel Core i9-11900K 3.50GHz, 1 CPU, 16 logical and 8 physical cores
.NET SDK 9.0.100-preview.4.24267.66
[Host] : .NET 8.0.5 (8.0.524.21615), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI
DefaultJob : .NET 8.0.5 (8.0.524.21615), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI

Before:

MethodMeanErrorStdDevRatioRatioSDGen0Gen1AllocatedAlloc Ratio
ParseQueryString516.0 ns7.83 ns6.94 ns1.000.000.1955-1.6 KB1.00
ParseQueryString_Mix429.1 ns5.26 ns4.92 ns0.830.010.19310.00051.58 KB0.99
ParseQueryString_Unicode691.2 ns10.41 ns9.74 ns1.340.030.2689-2.2 KB1.38

PR:

MethodMeanErrorStdDevRatioRatioSDGen0AllocatedAlloc Ratio
ParseQueryString489.3 ns4.92 ns4.36 ns1.000.000.1059888 B1.00
ParseQueryString_Mix338.7 ns2.76 ns2.45 ns0.690.010.0820688 B0.77
ParseQueryString_Unicode656.1 ns7.01 ns6.22 ns1.340.020.17171440 B1.62
samsosa reacted with rocket emoji

Copy link
Member

@MihaZupanMihaZupan left a comment

Choose a reason for hiding this comment

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

This is one weird class.
Thanks for taking care of these low-hanging fruit

PaulusParssinen reacted with laugh emoji
@MihaZupanMihaZupan merged commit49c10ed intodotnet:mainMay 29, 2024
@TrayanZapryanovTrayanZapryanov deleted the optimize_url_decoder branchMay 29, 2024 19:11
Ruihan-Yin pushed a commit to Ruihan-Yin/runtime that referenced this pull requestMay 30, 2024
@MihaZupanMihaZupan added this to the9.0.0 milestoneMay 31, 2024
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsJul 1, 2024
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@EgorBoEgorBoEgorBo left review comments

@TornhoofTornhoofTornhoof left review comments

@MihaZupanMihaZupanMihaZupan approved these changes

Assignees
No one assigned
Labels
area-System.Netcommunity-contributionIndicates that the PR has been added by a community member
Projects
None yet
Milestone
9.0.0
Development

Successfully merging this pull request may close these issues.

5 participants
@TrayanZapryanov@EgorBo@Tornhoof@MihaZupan@Trayan-Zapryanov

[8]ページ先頭

©2009-2025 Movatter.jp