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

strings: optimize ToLower() #60127

Closed
IGLOU-EU opened this issue May 11, 2023 · 1 comment
Closed

strings: optimize ToLower() #60127

IGLOU-EU opened this issue May 11, 2023 · 1 comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Performance
Milestone

Comments

@IGLOU-EU
Copy link

Hi,
I want to optimize the ToLower function and its dependencies.
Reduce memory allocation, early return...

Why

I made a small pkg for patern matching https://github.com/IGLOU-EU/go-wildcard
I wanted to add a "case-insensitive" option, but it loses a lot of performance, even for an empty string.

Bench

BenchmarkMatch/0-16             454892713            0.9726 ns/op           0 B/op          0 allocs/op
BenchmarkMatch/1-16             349304181            2.928 ns/op           0 B/op          0 allocs/op
BenchmarkMatch/2-16             476728009            2.127 ns/op           0 B/op          0 allocs/op
BenchmarkMatch/3-16             290518609            3.822 ns/op           0 B/op          0 allocs/op
BenchmarkMatch/4-16             124291632            8.709 ns/op           0 B/op          0 allocs/op
BenchmarkMatch/5-16             23469135            48.56 ns/op        0 B/op          0 allocs/op

BenchmarkMatchCasefold/0-16      7673000           216.3 ns/op        48 B/op          1 allocs/op
BenchmarkMatchCasefold/1-16      7057550           223.6 ns/op        48 B/op          1 allocs/op
BenchmarkMatchCasefold/2-16      6580888           215.7 ns/op        48 B/op          1 allocs/op
BenchmarkMatchCasefold/3-16      3193930           451.2 ns/op        96 B/op          2 allocs/op
BenchmarkMatchCasefold/4-16      3213775           473.1 ns/op        96 B/op          2 allocs/op
BenchmarkMatchCasefold/5-16      2305406           481.4 ns/op        32 B/op          1 allocs/op
@gopherbot gopherbot added this to the Proposal milestone May 11, 2023
@seankhliao seankhliao changed the title proposal: strings: optimize ToLower() strings: optimize ToLower() May 11, 2023
@seankhliao seankhliao added Performance NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. and removed Proposal labels May 11, 2023
@seankhliao seankhliao modified the milestones: Proposal, Backlog May 11, 2023
@seankhliao
Copy link
Member

If you can come up with a correct optimization, feel free to send a CL with benchmarks.
Otherwise I don't see anything actionable here.

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale May 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Performance
Projects
None yet
Development

No branches or pull requests

3 participants