Skip to content

String.IndexOf(string, int) is VERY slow on linux #41284

Closed
@laloutre87

Description

@laloutre87

Description

Code that was running fine previously on mono has became extremely slow with .Net Core 3.1 .
I found the bottleneck to be the String.IndexOf(string, int ) function.

Configuration

dotnet --version
3.1.401

debian_version 10.4
4.19.0-9-amd64 #1 SMP Debian 4.19.118-2+deb10u1 (2020-06-07) x86_64 GNU/Linux

Regression?

Regression compared to Mono 6.10.

Data

Small test program :
BugIndexOf.zip

Which displays on my windows laptop :

IndexOf(string, ... ) , found ";" 10000 times in 0,0206797 seconds
IndexOf(char, ... ) , found ';' 10000 times in 0,0006354 seconds

And on the linux server :

IndexOf(string, ... ) , found ";" 10000 times in 379,0305622 seconds
IndexOf(char, ... ) , found ';' 10000 times in 0,0006657 seconds

And the real-life scenario that affected me was the usage of this small piece of code (granted : not very optimized code !) made to deserialize data serialized by PHP, where deserializing the data took 70minutes instead of less than 2 seconds previously (Mono 6.10, same machine, same OS version, same code, same data). The code can be found here : https://gist.github.com/xiangwan/1225981/1f6d12679fe510ff241468561e0f80fa757f8db4

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions