Skip to content

Improve ProbabilisticMap performance for small value sets#85202

Merged
MihaZupan merged 1 commit intodotnet:mainfrom
MihaZupan:indexofanyvalues-prob-extendto8
Apr 23, 2023
Merged

Improve ProbabilisticMap performance for small value sets#85202
MihaZupan merged 1 commit intodotnet:mainfrom
MihaZupan:indexofanyvalues-prob-extendto8

Conversation

@MihaZupan
Copy link
Member

Since IndexOfAnyExcept does a value.Contains(c) on every input character, it's faster if the value is at least 8 characters long.

We could go further with e.g. working with a Vector128<ushort> directly instead of calling into Contains, but I don't know how common short inputs will actually be in practice.

Method Toolchain Length Mean Error Ratio
IndexOfAnyExcept6 main 10000 82.06 us 0.288 us 1.00
IndexOfAnyExcept6 pr 10000 31.00 us 0.491 us 0.38

@MihaZupan MihaZupan added this to the 8.0.0 milestone Apr 22, 2023
@MihaZupan MihaZupan requested a review from stephentoub April 22, 2023 20:14
@MihaZupan MihaZupan self-assigned this Apr 22, 2023
@ghost
Copy link

ghost commented Apr 22, 2023

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

Issue Details

Since IndexOfAnyExcept does a value.Contains(c) on every input character, it's faster if the value is at least 8 characters long.

We could go further with e.g. working with a Vector128<ushort> directly instead of calling into Contains, but I don't know how common short inputs will actually be in practice.

Method Toolchain Length Mean Error Ratio
IndexOfAnyExcept6 main 10000 82.06 us 0.288 us 1.00
IndexOfAnyExcept6 pr 10000 31.00 us 0.491 us 0.38
Author: MihaZupan
Assignees: MihaZupan
Labels:

area-System.Buffers

Milestone: 8.0.0

Copy link
Member

@stephentoub stephentoub left a comment

Choose a reason for hiding this comment

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

Clever.

@MihaZupan
Copy link
Member Author

Build failure is known according to Build Analysis

@MihaZupan MihaZupan merged commit 46101c4 into dotnet:main Apr 23, 2023
@ghost ghost locked as resolved and limited conversation to collaborators May 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants