Skip to content

Fix string.Split regression#130438

Open
hamarb123 wants to merge 15 commits into
dotnet:mainfrom
hamarb123:main35
Open

Fix string.Split regression#130438
hamarb123 wants to merge 15 commits into
dotnet:mainfrom
hamarb123:main35

Conversation

@hamarb123

@hamarb123 hamarb123 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Fixes #130418 (probably).

/cc @tannergooding

@hamarb123 hamarb123 marked this pull request as draft July 9, 2026 22:05
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Jul 9, 2026
@hamarb123 hamarb123 closed this Jul 9, 2026
@hamarb123

hamarb123 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

Nevermind, this won't fix it - misread the platform - will re-open when I fix the code.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

@hamarb123 hamarb123 reopened this Jul 9, 2026
@hamarb123

This comment was marked as outdated.

@hamarb123

Copy link
Copy Markdown
Contributor Author

@EgorBot -amd -arm -intel

using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using System.IO;
using System.Threading;
using System.Threading.Tasks;

BenchmarkSwitcher.FromAssembly(typeof(Bench).Assembly).Run(args);

public class Bench
{
        [Benchmark]
        [Arguments("A B C D E F G H I J K L M N O P Q R S T U V W X Y Z", new char[] { ' ' }, StringSplitOptions.None)]
        [Arguments("A B C D E F G H I J K L M N O P Q R S T U V W X Y Z", new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)]
        [Arguments("ABCDEFGHIJKLMNOPQRSTUVWXYZ", new char[]{' '}, StringSplitOptions.None)]
        [Arguments("ABCDEFGHIJKLMNOPQRSTUVWXYZ", new char[]{' '}, StringSplitOptions.RemoveEmptyEntries)]
        public string[] Split(string s, char[] arr, StringSplitOptions options)
            => s.Split(arr, options);
}

@hamarb123

This comment was marked as outdated.

@hamarb123

This comment was marked as outdated.

@hamarb123

This comment was marked as resolved.

@hamarb123

This comment was marked as resolved.

@hamarb123

Copy link
Copy Markdown
Contributor Author

@MihuBot -arm

@hamarb123

Copy link
Copy Markdown
Contributor Author

@EgorBot -ubuntu24_azure_cobalt100

using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using System.IO;
using System.Threading;
using System.Threading.Tasks;

BenchmarkSwitcher.FromAssembly(typeof(Bench).Assembly).Run(args);

public class Bench
{
        [Benchmark]
        [Arguments("A B C D E F G H I J K L M N O P Q R S T U V W X Y Z", new char[] { ' ' }, StringSplitOptions.None)]
        [Arguments("A B C D E F G H I J K L M N O P Q R S T U V W X Y Z", new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)]
        [Arguments("ABCDEFGHIJKLMNOPQRSTUVWXYZ", new char[]{' '}, StringSplitOptions.None)]
        [Arguments("ABCDEFGHIJKLMNOPQRSTUVWXYZ", new char[]{' '}, StringSplitOptions.RemoveEmptyEntries)]
        public string[] Split(string s, char[] arr, StringSplitOptions options)
            => s.Split(arr, options);
}

@hamarb123

This comment was marked as outdated.

{
Vector128<ushort> vector = Vector128.Create(sourceSpanUInt16.Slice(sourceSpanUInt16.Length - Vector128<ushort>.Count));
Debug.Assert(sourceSpanUInt16.Length >= Vector128<ushort>.Count);
Vector128<ushort> vector = Vector128.LoadUnsafe(in MemoryMarshal.GetReference(sourceSpanUInt16), (uint)(sourceSpanUInt16.Length - Vector128<ushort>.Count));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

please don't replace safe code with unsafe

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It was unsafe before the PR that introduced the regression. Part of the regression is likely the bounds check that exists here now.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That PR removed a lot more unsafe than just this one spot, and we only need to add this one spot back to get no bounds checks - surely that is fine?

@hamarb123

Copy link
Copy Markdown
Contributor Author

@EgorBot -ubuntu24_azure_cobalt100

using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using System.IO;
using System.Threading;
using System.Threading.Tasks;

BenchmarkSwitcher.FromAssembly(typeof(Bench).Assembly).Run(args);

public class Bench
{
        [Benchmark]
        [Arguments("A B C D E F G H I J K L M N O P Q R S T U V W X Y Z", new char[] { ' ' }, StringSplitOptions.None)]
        [Arguments("A B C D E F G H I J K L M N O P Q R S T U V W X Y Z", new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)]
        [Arguments("ABCDEFGHIJKLMNOPQRSTUVWXYZ", new char[]{' '}, StringSplitOptions.None)]
        [Arguments("ABCDEFGHIJKLMNOPQRSTUVWXYZ", new char[]{' '}, StringSplitOptions.RemoveEmptyEntries)]
        public string[] Split(string s, char[] arr, StringSplitOptions options)
            => s.Split(arr, options);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-System.Runtime community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Perf] Linux/arm64: 3 Regressions on 7/5/2026 2:44:21 PM +00:00

2 participants