Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IrcParser: make public and speed up by another <=15% #247

Merged
merged 2 commits into from
Aug 11, 2023

Conversation

neon-sunset
Copy link

Supersedes #217

Description

We can now make IrcParser public and it will do the right thing (tm) when utilized from user code.

  • Add missing doc comments
  • Add null/short string guard
  • Improve parser perf. by another up to 15% depending on runtime by improving SplitFirst/Last logic (adopting learnings from working on another project)

To be honest, it is pretty meaningless to continue improving parsing performance since TwitchLib impl. is now faster than popular alternatives in Java, Rust and Go (some of them kind of shoot themselves in the foot though). But hey, neuron activation.

Numbers

(before version supposedly roll-forwarded to a newer compiler version too so runtime perf. differences should not be significant)
Before:

BenchmarkDotNet=v0.13.5, OS=macOS 14.0 [Darwin 23.0.0]
Apple M1 Pro, 1 CPU, 8 logical and 8 physical cores
.NET SDK=8.0.100-preview.6.23316.13
  [Host]     : .NET 7.0.1 (7.0.122.56804), Arm64 RyuJIT AdvSIMD
  DefaultJob : .NET 7.0.1 (7.0.122.56804), Arm64 RyuJIT AdvSIMD
Method Message Mean Error StdDev Gen0 Gen1 Allocated
Parse :blub(...) list [66] 76.47 ns 0.191 ns 0.178 ns 0.0587 - 368 B
Parse :jtv(...)ers. [100] 76.21 ns 0.227 ns 0.201 ns 0.0573 - 360 B
Parse @bad(...)senE [884] 856.95 ns 2.589 ns 2.295 ns 0.5836 0.0048 3664 B
Parse @bad(...)Guys [382] 739.43 ns 1.645 ns 1.458 ns 0.4101 0.0010 2576 B
Parse @msg-(...)live. [74] 122.61 ns 0.380 ns 0.355 ns 0.0994 - 624 B
Parse @msg(...)ces. [110] 127.62 ns 0.280 ns 0.262 ns 0.1109 - 696 B

After:

BenchmarkDotNet v0.13.7, macOS Sonoma 14.0 (23A5301h) [Darwin 23.0.0]
Apple M1 Pro, 1 CPU, 8 logical and 8 physical cores
.NET SDK 8.0.100-rc.1.23404.1
  [Host]     : .NET 8.0.0 (8.0.23.38103), Arm64 RyuJIT AdvSIMD
  DefaultJob : .NET 8.0.0 (8.0.23.38103), Arm64 RyuJIT AdvSIMD
Method Message Mean Error StdDev Gen0 Gen1 Allocated
Parse :blub(...) list [66] 75.10 ns 0.233 ns 0.194 ns 0.0714 - 448 B
Parse :jtv(...)ers. [100] 73.24 ns 0.280 ns 0.262 ns 0.0701 - 440 B
Parse @bad(...)senE [884] 696.84 ns 1.085 ns 0.962 ns 0.5836 0.0038 3664 B
Parse @bad(...)Guys [382] 586.12 ns 1.104 ns 0.922 ns 0.4101 0.0010 2576 B
Parse @msg-(...)live. [74] 106.09 ns 0.175 ns 0.155 ns 0.0994 0.0001 624 B
Parse @msg(...)ces. [110] 109.15 ns 0.183 ns 0.163 ns 0.1109 - 696 B

@Syzuna Syzuna merged commit 5fea08f into TwitchLib:dev Aug 11, 2023
1 check passed
@neon-sunset neon-sunset deleted the make-ircparser-public branch August 11, 2023 15:08
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.

4 participants