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

Improve Ascii.FromUtf16 and FromHexString#102735

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
tannergooding merged 2 commits intodotnet:mainfromMihaZupan:cheaper-vector-narrow
May 29, 2024

Conversation

MihaZupan
Copy link
Member

@MihaZupanMihaZupan commentedMay 27, 2024
edited
Loading

We're already using things likeSse2.PackUnsignedSaturate instead ofVector128.Narrow when we don't care about the edge case values (we've already validated the input).
This PR does something similar forVector256 andVector512 paths.

publicclassAsciiBenchmarks{[Params(1000)]publicintLength;privatebyte[]_bytes;privatechar[]_chars;[GlobalSetup]publicvoidSetup(){_chars=newstring('a',Length).ToCharArray();_bytes=Encoding.ASCII.GetBytes(_chars);}[Benchmark]publicOperationStatusFromUtf16()=>Ascii.FromUtf16(_chars,_bytes,out_);[Benchmark]publicOperationStatusFromHexString()=>Convert.FromHexString(_chars,_bytes,out_,out_);}
MethodToolchainLengthMeanErrorRatio
FromUtf16main100045.37 ns0.057 ns1.00
FromUtf16pr100032.70 ns0.163 ns0.72
FromHexStringmain1000144.48 ns0.097 ns1.00
FromHexStringpr1000102.58 ns0.079 ns0.71

(this is with Avx2)

Diffs:https://gist.github.com/MihuBot/f60c7254060f436ae9c12ded701c85f8

EgorBo, neon-sunset, PaulusParssinen, and omariom reacted with thumbs up emojidanmoseley, ShreyasJejurkar, and PaulusParssinen reacted with rocket emoji
@dotnet-policy-serviceDotnet Policy Service
Copy link
Contributor

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

@EgorBo
Copy link
Member

@EgorBot -intel -amd --disasm

usingBenchmarkDotNet.Attributes;usingSystem.Buffers;usingSystem.Text;usingSystem;usingBenchmarkDotNet.Running;BenchmarkRunner.Run<AsciiBenchmarks>(args:args);publicclassAsciiBenchmarks{[Params(1000)]publicintLength;privatebyte[]_bytes;privatechar[]_chars;[GlobalSetup]publicvoidSetup(){_chars=newstring('a',Length).ToCharArray();_bytes=Encoding.ASCII.GetBytes(_chars);}[Benchmark]publicOperationStatusFromUtf16()=>Ascii.FromUtf16(_chars,_bytes,out_);}
MihaZupan, ShreyasJejurkar, and PaulusParssinen reacted with hooray emojiomariom reacted with heart emoji

@EgorBot
Copy link

BenchmarkDotNet v0.13.12, Ubuntu 22.04.4 LTS (Jammy Jellyfish)Intel Xeon Platinum 8370C CPU 2.80GHz, 1 CPU, 16 logical and 8 physical cores  Job-BWGLXM : .NET 9.0.0 (42.42.42.42424), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI  Job-ULJSQF : .NET 9.0.0 (42.42.42.42424), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI
MethodToolchainLengthMeanErrorRatioCode Size
FromUtf16Main100034.96 ns0.007 ns1.001,104 B
FromUtf16PR100027.99 ns0.006 ns0.801,033 B
More data

SeeBDN_Artifacts.zip for details.

ShreyasJejurkar reacted with heart emoji

@EgorBot
Copy link

BenchmarkDotNet v0.13.12, Ubuntu 22.04.4 LTS (Jammy Jellyfish)AMD EPYC 7763, 1 CPU, 16 logical and 8 physical cores  Job-NUESEZ : .NET 9.0.0 (42.42.42.42424), X64 RyuJIT AVX2  Job-WIGDOZ : .NET 9.0.0 (42.42.42.42424), X64 RyuJIT AVX2
MethodToolchainLengthMeanErrorRatioCode Size
FromUtf16Main100033.02 ns0.004 ns1.00796 B
FromUtf16PR100023.83 ns0.006 ns0.72760 B
More data

SeeBDN_Artifacts.zip for details.

ShreyasJejurkar reacted with heart emoji

@ShreyasJejurkar
Copy link
Contributor

Whooooo nice bot@EgorBo. Pretty interesting...😅🧐

@MihaZupan
Copy link
MemberAuthor

@EgorBot -arm64 -amd --disasm

usingBenchmarkDotNet.Attributes;usingSystem.Buffers;usingSystem.Text;usingSystem;usingBenchmarkDotNet.Running;BenchmarkRunner.Run<AsciiBenchmarks>(args:args);publicclassAsciiBenchmarks{[Params(1000)]publicintLength;privatebyte[]_bytes;privatechar[]_chars;[GlobalSetup]publicvoidSetup(){_chars=newstring('a',Length).ToCharArray();_bytes=Encoding.ASCII.GetBytes(_chars);}[Benchmark]publicOperationStatusFromHexString()=>Convert.FromHexString(_chars,_bytes,out_,out_);}

@EgorBot
Copy link

EgorBot commentedMay 28, 2024
edited by EgorBo
Loading

BenchmarkDotNet v0.13.12, Ubuntu 22.04.4 LTS (Jammy Jellyfish)Intel Xeon Platinum 8370C CPU 2.80GHz, 1 CPU, 16 logical and 8 physical cores  Job-KKQGMF : .NET 9.0.0 (42.42.42.42424), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI  Job-GAATJR : .NET 9.0.0 (42.42.42.42424), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI
MethodToolchainLengthMeanErrorRatio
FromHexStringMain1000131.7 ns0.11 ns1.00
FromHexStringPR1000115.3 ns0.02 ns0.88
More data

SeeBDN_Artifacts.zip for details.

@dotnetdotnet deleted a comment fromEgorBotMay 28, 2024
@tannergoodingtannergooding merged commit5c74f63 intodotnet:mainMay 29, 2024
Ruihan-Yin pushed a commit to Ruihan-Yin/runtime that referenced this pull requestMay 30, 2024
* Use cheaper Vector.Narrow altenatives in Ascii* Use existing Ascii helper in HexConverter
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsJun 29, 2024
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@tannergoodingtannergoodingtannergooding approved these changes

Assignees

@MihaZupanMihaZupan

Projects
None yet
Milestone
9.0.0
Development

Successfully merging this pull request may close these issues.

5 participants
@MihaZupan@EgorBo@EgorBot@ShreyasJejurkar@tannergooding

[8]ページ先頭

©2009-2025 Movatter.jp