Skip to content

strings: optimize ToLower() #60127

Closed as not planned
Closed as not planned

Description

@IGLOU-EU

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

Activity

  1. added this to the Proposal milestone on May 11, 2023
  2. changed the title [-]proposal: strings: optimize ToLower()[/-] [+]strings: optimize ToLower()[/+] on May 11, 2023
  3. added
    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.
    and removed on May 11, 2023
  4. modified the milestones: Proposal, Backlog on May 11, 2023
  5. seankhliao commented on May 11, 2023

    @seankhliao
    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.

  6. locked and limited conversation to collaborators on May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Performance

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions