-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Labels
NeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.compiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.
Milestone
Description
Hi, Go team.
I'm working on optimizing iterating over map for an internal data encoding project.
And in our case, I found that one of the bottlenecks is reflect.MapIter
.Next
.
It can be improved by removing calling mapiterkey
.
coz we have already copiedhiter
struct from runtime
for performance concern.
To make it further, we can use key
and elem
of hiter
struct directly without calling mapiterkey
and mapiterelem
This mainly impacts the Next
method of reflect.MapIter
.
I ran the BenchmarkMapIterNext
benchmark in reflect/benchmark_test.go
, and here is the output:
goos: darwin
goarch: arm64
pkg: reflect
cpu: Apple M2 Pro
│ ./old.txt │ ./new.txt │
│ sec/op │ sec/op vs base │
MapIterNext-12 61.44n ± 1% 54.51n ± 1% -11.29% (p=0.000 n=10)
I would like to raise CR if you're OK with it.
Metadata
Metadata
Assignees
Labels
NeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.compiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.
Type
Projects
Status
Done