Merged
Conversation
|
Tagging subscribers to this area: @dotnet/ncl |
Member
|
Should this benchmarks be incorporated to Perf_Uri? |
Member
Author
|
Yes, the list of Uri-related benchmarks should be extended in the perf repo |
danmoseley
reviewed
May 23, 2020
Member
Author
|
The change in the hex decoding also improves perf for [Benchmark]
public string UnescapeDataString_ReservedAscii() => Uri.UnescapeDataString("%3F%20%3E%21%3F%20%3E%21%3F%20%3E%21%3F%20%3E%21%3F%20%3E%21");
|
stephentoub
reviewed
May 26, 2020
| if (c == '%') | ||
| { | ||
| if (i + 2 < data.Length) | ||
| if ((uint)(i + 2) < (uint)data.Length) |
Member
There was a problem hiding this comment.
Same question as on the other PR; does this uint casting actually enable the JIT to eliminate the i+1 and i+2 bounds checks? If it does, great; I just didn't think it did.
Member
Author
There was a problem hiding this comment.
I measured it against a completely unsafe version and the perf is: (new being the unsafe variant)
| Method | Toolchain | Mean | Error | StdDev | Median | Ratio | RatioSD |
|---|---|---|---|---|---|---|---|
| Ascii | \perf-base\CoreRun.exe | 157.4 ns | 0.26 ns | 1.33 ns | 157.0 ns | 0.95 | 0.01 |
| Ascii | \perf-new\CoreRun.exe | 165.7 ns | 0.34 ns | 1.68 ns | 165.5 ns | 1.00 | 0.00 |
| PercentEncoded | \perf-base\CoreRun.exe | 192.7 ns | 1.94 ns | 9.67 ns | 186.9 ns | 0.98 | 0.05 |
| PercentEncoded | \perf-new\CoreRun.exe | 196.7 ns | 0.25 ns | 1.22 ns | 196.6 ns | 1.00 | 0.00 |
That said, I'll merge it as-is
stephentoub
approved these changes
May 26, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reduces the initial overhead for every Uri ctor.
Will also improve perf for any processing that calls into
UriHelper.EscapedAscii- anywhere we unescape percent-encoded values.