-
Notifications
You must be signed in to change notification settings - Fork 18.4k
all: replace strings.Split with strings.SplitSeq #75259
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
base: master
Are you sure you want to change the base?
Conversation
This PR (HEAD: c93496b) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/go/+/701015. Important tips:
|
Message from Gopher Robot: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/701015. |
Message from 黄志文: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/701015. |
Message from 黄志文: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/701015. |
Message from qiu laidongfeng: Patch Set 1: Commit-Queue+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/701015. |
Message from Go LUCI: Patch Set 1: Dry run: CV is trying the patch. Bot data: {"action":"start","triggered_at":"2025-09-04T16:53:30Z","revision":"36dbe0cc13b6a7c04877462eb74fd3bb4756b18a"} Please don’t reply on this GitHub thread. Visit golang.org/cl/701015. |
Message from qiu laidongfeng: Patch Set 1: -Commit-Queue Please don’t reply on this GitHub thread. Visit golang.org/cl/701015. |
Message from Go LUCI: Patch Set 1: This CL has passed the run Please don’t reply on this GitHub thread. Visit golang.org/cl/701015. |
Message from Go LUCI: Patch Set 1: LUCI-TryBot-Result+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/701015. |
Message from Keith Randall: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/701015. |
Message from 黄志文: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/701015. |
Message from 黄志文: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/701015. |
Message from Emmanuel Odeke: Patch Set 1: Commit-Queue+1 Run-TryBot+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/701015. |
Message from Go LUCI: Patch Set 1: Dry run: CV is trying the patch. Bot data: {"action":"start","triggered_at":"2025-09-05T07:23:38Z","revision":"36dbe0cc13b6a7c04877462eb74fd3bb4756b18a"} Please don’t reply on this GitHub thread. Visit golang.org/cl/701015. |
Message from Gopher Robot: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/701015. |
Message from Emmanuel Odeke: Patch Set 1: -Commit-Queue Please don’t reply on this GitHub thread. Visit golang.org/cl/701015. |
Message from Go LUCI: Patch Set 1: This CL has passed the run Please don’t reply on this GitHub thread. Visit golang.org/cl/701015. |
Message from 黄志文: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/701015. |
This PR (HEAD: f56319c) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/go/+/701015. Important tips:
|
Message from 黄志文: Patch Set 2: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/701015. |
Message from Emmanuel Odeke: Patch Set 2: Commit-Queue+1 Run-TryBot+1 (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/701015. |
Message from Go LUCI: Patch Set 2: Dry run: CV is trying the patch. Bot data: {"action":"start","triggered_at":"2025-09-05T13:21:28Z","revision":"1a1afff20ad94e562697e6d83b03334345f93a42"} Please don’t reply on this GitHub thread. Visit golang.org/cl/701015. |
Message from Gopher Robot: Patch Set 2: (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/701015. |
Message from 黄志文: Patch Set 2: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/701015. |
Message from Emmanuel Odeke: Patch Set 2: -Commit-Queue Please don’t reply on this GitHub thread. Visit golang.org/cl/701015. |
Message from Go LUCI: Patch Set 2: This CL has failed the run. Reason: Tryjob golang/try/gotip-windows-amd64-longtest has failed with summary (view all results):
To reproduce, try Additional links for debugging: Please don’t reply on this GitHub thread. Visit golang.org/cl/701015. |
Message from Go LUCI: Patch Set 2: LUCI-TryBot-Result-1 Please don’t reply on this GitHub thread. Visit golang.org/cl/701015. |
Message from 黄志文: Patch Set 2: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/701015. |
Message from 黄志文: Patch Set 2: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/701015. |
This PR (HEAD: 9e9bd04) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/go/+/701015. Important tips:
|
Message from 黄志文: Patch Set 3: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/701015. |
This PR (HEAD: 4db66ee) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/go/+/701015. Important tips:
|
Message from Sean Liao: Patch Set 4: Commit-Queue+1 (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/701015. |
Message from Go LUCI: Patch Set 4: Dry run: CV is trying the patch. Bot data: {"action":"start","triggered_at":"2025-09-06T09:18:35Z","revision":"1089ed7c6dc8eba046706937e3a771e0ce8ced21"} Please don’t reply on this GitHub thread. Visit golang.org/cl/701015. |
Message from Sean Liao: Patch Set 4: -Commit-Queue Please don’t reply on this GitHub thread. Visit golang.org/cl/701015. |
Message from Go LUCI: Patch Set 4: This CL has passed the run Please don’t reply on this GitHub thread. Visit golang.org/cl/701015. |
Message from Go LUCI: Patch Set 4: LUCI-TryBot-Result+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/701015. |
Message from 黄志文: Patch Set 5: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/701015. |
Message from Sean Liao: Patch Set 5: (3 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/701015. |
Message from 黄志文: Patch Set 5: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/701015. |
Message from 黄志文: Patch Set 5: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/701015. |
Message from 黄志文: Patch Set 5: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/701015. |
Message from Keith Randall: Patch Set 5: Code-Review+2 (4 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/701015. |
In Go 1.25+, strings.SplitSeq offers better performance.
Here are the benchmark results comparing strings.Split
and strings.SplitSeq in a for-loop, with the benchmark
code located in src/strings/iter_test.go:
goos: darwin
goarch: amd64
pkg: strings
cpu: Intel(R) Core(TM) i7-8569U CPU @ 2.80GHz
BenchmarkSplitAndSplitSeq
BenchmarkSplitAndSplitSeq/bySplit_Key_found
BenchmarkSplitAndSplitSeq/bySplit_Key_found-8 14313253 83.19 ns/op 64 B/op 1 allocs/op
BenchmarkSplitAndSplitSeq/bySplitSeq_Key_found
BenchmarkSplitAndSplitSeq/bySplitSeq_Key_found-8 39103686 31.47 ns/op 0 B/op 0 allocs/op
BenchmarkSplitAndSplitSeq/bySplit_Key_not_found
BenchmarkSplitAndSplitSeq/bySplit_Key_not_found-8 11282700 93.85 ns/op 64 B/op 1 allocs/op
BenchmarkSplitAndSplitSeq/bySplitSeq_Key_not_found
BenchmarkSplitAndSplitSeq/bySplitSeq_Key_not_found-8 30754255 39.44 ns/op 0 B/op 0 allocs/op
ParseSpectreNew/empty-8 32.205n ± 1% 9.457n ± 2% -70.64% (p=0.000 n=10)
ParseSpectreNew/index-8 34.76n ± 2% 11.46n ± 4% -67.03% (p=0.000 n=10)
ParseSpectreNew/ret-8 34.65n ± 5% 11.15n ± 2% -67.84% (p=0.000 n=10)
ParseSpectreNew/index_ret-8 50.21n ± 2% 20.98n ± 2% -58.22% (p=0.000 n=10)
ParseSpectreNew/all-8 35.19n ± 3% 11.25n ± 2% -68.02% (p=0.000 n=10)
ParseSpectreNew/multiple_indices_ret-8 195.2n ± 1% 125.1n ± 2% -35.90% (p=0.000 n=10)
geomean 48.72n 18.15n -62.76%
ParseSpectreNew/empty-8 16.00 ± 0% 0.00 ± 0% -100.00% (p=0.000 n=10)
ParseSpectreNew/index-8 16.00 ± 0% 0.00 ± 0% -100.00% (p=0.000 n=10)
ParseSpectreNew/ret-8 16.00 ± 0% 0.00 ± 0% -100.00% (p=0.000 n=10)
ParseSpectreNew/index_ret-8 32.00 ± 0% 0.00 ± 0% -100.00% (p=0.000 n=10)
ParseSpectreNew/all-8 16.00 ± 0% 0.00 ± 0% -100.00% (p=0.000 n=10)
ParseSpectreNew/multiple_indices_ret-8 176.0 ± 0% 0.0 ± 0% -100.00% (p=0.000 n=10)
geomean 26.78 ? ¹ ²
¹ summaries must be >0 to compute geomean
² ratios must be >0 to compute geomean
ParseSpectreNew/empty-8 1.000 ± 0% 0.000 ± 0% -100.00% (p=0.000 n=10)
ParseSpectreNew/index-8 1.000 ± 0% 0.000 ± 0% -100.00% (p=0.000 n=10)
ParseSpectreNew/ret-8 1.000 ± 0% 0.000 ± 0% -100.00% (p=0.000 n=10)
ParseSpectreNew/index_ret-8 1.000 ± 0% 0.000 ± 0% -100.00% (p=0.000 n=10)
ParseSpectreNew/all-8 1.000 ± 0% 0.000 ± 0% -100.00% (p=0.000 n=10)
ParseSpectreNew/multiple_indices_ret-8 1.000 ± 0% 0.000 ± 0% -100.00% (p=0.000 n=10)
geomean 1.000 ? ¹ ²
¹ summaries must be >0 to compute geomean
² ratios must be >0 to compute geomean
goos: darwin
goarch: amd64
pkg: cmd/go/internal/auth
cpu: Intel(R) Core(TM) i7-8569U CPU @ 2.80GHz
│ old.txt │ new.txt │
│ sec/op │ sec/op vs base │
ParseGitAuth/standard-8 281.4n ± 1% 218.0n ± 11% -22.54% (p=0.000 n=10)
ParseGitAuth/with_url-8 549.1n ± 1% 480.5n ± 13% -12.48% (p=0.002 n=10)
ParseGitAuth/minimal-8 235.4n ± 1% 197.3n ± 7% -16.20% (p=0.000 n=10)
ParseGitAuth/complex-8 797.6n ± 2% 805.2n ± 4% ~ (p=0.481 n=10)
ParseGitAuth/empty-8 87.48n ± 3% 63.25n ± 6% -27.71% (p=0.000 n=10)
ParseGitAuth/malformed-8 228.8n ± 1% 171.2n ± 3% -25.17% (p=0.000 n=10)
geomean 288.9n 237.7n -17.72%
ParseGitAuth/standard-8 192.00 ± 0% 96.00 ± 0% -50.00% (p=0.000 n=10)
ParseGitAuth/with_url-8 400.0 ± 0% 288.0 ± 0% -28.00% (p=0.000 n=10)
ParseGitAuth/minimal-8 144.00 ± 0% 80.00 ± 0% -44.44% (p=0.000 n=10)
ParseGitAuth/complex-8 528.0 ± 0% 400.0 ± 0% -24.24% (p=0.000 n=10)
ParseGitAuth/empty-8 32.00 ± 0% 16.00 ± 0% -50.00% (p=0.000 n=10)
ParseGitAuth/malformed-8 176.00 ± 0% 80.00 ± 0% -54.55% (p=0.000 n=10)
geomean 179.0 102.1 -42.96%
ParseGitAuth/standard-8 3.000 ± 0% 2.000 ± 0% -33.33% (p=0.000 n=10)
ParseGitAuth/with_url-8 4.000 ± 0% 3.000 ± 0% -25.00% (p=0.000 n=10)
ParseGitAuth/minimal-8 3.000 ± 0% 2.000 ± 0% -33.33% (p=0.000 n=10)
ParseGitAuth/complex-8 4.000 ± 0% 3.000 ± 0% -25.00% (p=0.000 n=10)
ParseGitAuth/empty-8 2.000 ± 0% 1.000 ± 0% -50.00% (p=0.000 n=10)
ParseGitAuth/malformed-8 3.000 ± 0% 2.000 ± 0% -33.33% (p=0.000 n=10)
geomean 3.086 2.040 -33.91%