-
Notifications
You must be signed in to change notification settings - Fork 18k
slices: optimize Compact and CompactFunc #64273
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
Conversation
This PR (HEAD: d642ac1) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/go/+/543661. Important tips:
|
Message from Gopher Robot: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/543661. |
Message from Xu Liu: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/543661. |
Message from Xu Liu: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/543661. |
Message from Xu Liu: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/543661. |
Message from Xu Liu: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/543661. |
This PR (HEAD: a912a34) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/go/+/543661. Important tips:
|
This PR (HEAD: d2236ae) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/go/+/543661. Important tips:
|
Message from Xu Liu: Patch Set 3: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/543661. |
This PR (HEAD: 5df3a7a) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/go/+/543661. Important tips:
|
Message from Xu Liu: Patch Set 6: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/543661. |
This PR (HEAD: cea3d93) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/go/+/543661. Important tips:
|
Message from Keith Randall: Patch Set 8: Auto-Submit+1 Code-Review+2 Commit-Queue+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/543661. |
Message from Go LUCI: Patch Set 8: Dry run: CV is trying the patch. Bot data: {"action":"start","triggered_at":"2023-11-28T21:43:24Z","revision":"017dc099225d00d172b4e7017fe1a7fd45c1bd33"} Please don’t reply on this GitHub thread. Visit golang.org/cl/543661. |
Message from Keith Randall: Patch Set 8: Code-Review+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/543661. |
Message from Keith Randall: Patch Set 8: -Commit-Queue Please don’t reply on this GitHub thread. Visit golang.org/cl/543661. |
Message from Go LUCI: Patch Set 8: This CL has passed the run Please don’t reply on this GitHub thread. Visit golang.org/cl/543661. |
Message from Go LUCI: Patch Set 8: LUCI-TryBot-Result+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/543661. |
Message from Xu Liu: Patch Set 8: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/543661. |
Message from Keith Randall: Patch Set 8: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/543661. |
Message from Ian Lance Taylor: Patch Set 8: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/543661. |
Message from Xu Liu: Patch Set 8: (3 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/543661. |
Try to save a comparison in the loop bodies of Compact and CompactFunc. Note: due to #64272, some bound checks still fail to be removed. │ old.txt │ new.txt │ │ sec/op │ sec/op vs base │ Compact/nil-4 4.191n ± 9% 3.402n ± 1% -18.84% (p=0.000 n=10) Compact/one-4 5.289n ± 2% 4.553n ± 2% -13.93% (p=0.000 n=10) Compact/sorted-4 9.865n ± 0% 6.882n ± 1% -30.24% (p=0.000 n=10) Compact/2_items-4 11.10n ± 2% 12.11n ± 2% +9.00% (p=0.000 n=10) Compact/unsorted-4 9.831n ± 3% 6.918n ± 2% -29.62% (p=0.000 n=10) Compact/many-4 16.40n ± 4% 14.90n ± 1% -9.20% (p=0.000 n=10) Compact/dup_start-4 29.87n ± 0% 28.06n ± 3% -6.04% (p=0.001 n=10) Compact_Large/all_dup-4 13.11µ ± 0% 13.12µ ± 0% ~ (p=0.971 n=10) Compact_Large/no_dup-4 6.972µ ± 0% 5.806µ ± 0% -16.73% (p=0.000 n=10) CompactFunc/nil-4 5.300n ± 0% 5.309n ± 1% ~ (p=0.289 n=10) CompactFunc/one-4 6.051n ± 1% 6.442n ± 3% +6.46% (p=0.000 n=10) CompactFunc/sorted-4 16.24n ± 1% 12.79n ± 2% -21.24% (p=0.000 n=10) CompactFunc/2_items-4 17.89n ± 1% 17.75n ± 0% -0.75% (p=0.000 n=10) CompactFunc/unsorted-4 16.26n ± 0% 12.83n ± 1% -21.07% (p=0.000 n=10) CompactFunc/many-4 30.71n ± 1% 29.07n ± 0% -5.32% (p=0.000 n=10) CompactFunc/dup_start-4 78.94n ± 1% 67.19n ± 1% -14.89% (p=0.000 n=10) CompactFunc_Large/all_dup-4 3.277m ± 0% 3.692m ± 2% +12.67% (p=0.000 n=10) CompactFunc_Large/no_dup-4 4.019m ± 0% 2.826m ± 1% -29.68% (p=0.000 n=10) geomean 109.6n 96.99n -11.47% Change-Id: Ia4c78fa62e7e9f4ff6a39d0e0a0a84cecf79b9cb GitHub-Last-Rev: cea3d93 GitHub-Pull-Request: #64273 Reviewed-on: https://go-review.googlesource.com/c/go/+/543661 Reviewed-by: Keith Randall <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Keith Randall <[email protected]> Reviewed-by: Joedian Reid <[email protected]> Auto-Submit: Keith Randall <[email protected]>
This PR is being closed because golang.org/cl/543661 has been merged. |
Try to save a comparison in the loop bodies of Compact and CompactFunc.
Note: due to #64272, some bound checks still fail to be removed.
Compact/nil-4 4.191n ± 9% 3.402n ± 1% -18.84% (p=0.000 n=10)
Compact/one-4 5.289n ± 2% 4.553n ± 2% -13.93% (p=0.000 n=10)
Compact/sorted-4 9.865n ± 0% 6.882n ± 1% -30.24% (p=0.000 n=10)
Compact/2_items-4 11.10n ± 2% 12.11n ± 2% +9.00% (p=0.000 n=10)
Compact/unsorted-4 9.831n ± 3% 6.918n ± 2% -29.62% (p=0.000 n=10)
Compact/many-4 16.40n ± 4% 14.90n ± 1% -9.20% (p=0.000 n=10)
Compact/dup_start-4 29.87n ± 0% 28.06n ± 3% -6.04% (p=0.001 n=10)
Compact_Large/all_dup-4 13.11µ ± 0% 13.12µ ± 0% ~ (p=0.971 n=10)
Compact_Large/no_dup-4 6.972µ ± 0% 5.806µ ± 0% -16.73% (p=0.000 n=10)
CompactFunc/nil-4 5.300n ± 0% 5.309n ± 1% ~ (p=0.289 n=10)
CompactFunc/one-4 6.051n ± 1% 6.442n ± 3% +6.46% (p=0.000 n=10)
CompactFunc/sorted-4 16.24n ± 1% 12.79n ± 2% -21.24% (p=0.000 n=10)
CompactFunc/2_items-4 17.89n ± 1% 17.75n ± 0% -0.75% (p=0.000 n=10)
CompactFunc/unsorted-4 16.26n ± 0% 12.83n ± 1% -21.07% (p=0.000 n=10)
CompactFunc/many-4 30.71n ± 1% 29.07n ± 0% -5.32% (p=0.000 n=10)
CompactFunc/dup_start-4 78.94n ± 1% 67.19n ± 1% -14.89% (p=0.000 n=10)
CompactFunc_Large/all_dup-4 3.277m ± 0% 3.692m ± 2% +12.67% (p=0.000 n=10)
CompactFunc_Large/no_dup-4 4.019m ± 0% 2.826m ± 1% -29.68% (p=0.000 n=10)
geomean 109.6n 96.99n -11.47%