runtime: reduce duplicate work by merging map operations #70837
Labels
compiler/runtime
Issues related to the Go compiler and/or runtime.
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Performance
Milestone
This is a
mapaccess2
followed (conditionally) by amapassign
. The beginning ofmapassign
is identical tomapaccess2
: hashing the key and looking for an existing entry (which won't be found).In theory, the compiler could detect this pattern and use a special call for the map assignment that avoids the duplicate work (this would effectively be
internal/runtime/maps.(*table).uncheckedPutSlot
in today's implementation).Another pattern is iteration plus delete:
It could be optimized in a similar way. This is also
maps.DeleteFunc
which could be directly specialized more easily than adding new compiler optimizations.The text was updated successfully, but these errors were encountered: