Closed xiaost closed 1 month ago
Related Issues and Documentation
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
In general, performance improvements with no user visible effect can just be submitted. A proposal doesn't need to be approved first unless it's doing something unusual to get the performance.
Change https://go.dev/cl/612616 mentions this issue: reflect: remove calling mapiterkey, mapiterelem
Taking this out of the proposal process.
Change https://go.dev/cl/613395 mentions this issue: reflect: allow inlining mapiterkey/mapiterelem
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 callingmapiterkey
.coz we have already copied
hiter
struct fromruntime
for performance concern. To make it further, we can usekey
andelem
ofhiter
struct directly without callingmapiterkey
andmapiterelem
This mainly impacts the
Next
method ofreflect.MapIter
. I ran theBenchmarkMapIterNext
benchmark inreflect/benchmark_test.go
, and here is the output:I would like to raise CR if you're OK with it.