1
0
mirror of https://github.com/golang/go synced 2024-11-24 07:00:13 -07:00
The Go programming language
Go to file
Joe Tsai 23832ba2e2 reflect: optimize for maps with string keys
Over 80% of all Go map types use a string as the key.
The Go runtime already has a specialized implementation for such maps
in runtime/map_faststr.go. However, the Go reflection implementation
has not historically made use of that implementation.

This CL plumbs the appropriate logic to be accessible from Go reflection
so that it can benefit as well.

    name                            old time/op    new time/op    delta
    Map/StringKeys/MapIndex-4       4.65us ± 5%    2.95us ± 3%  -36.50%  (p=0.016 n=4+5)
    Map/StringKeys/SetMapIndex-4    7.47us ± 5%    5.27us ± 2%  -29.40%  (p=0.008 n=5+5)
    Map/Uint64Keys/MapIndex-4       3.79us ± 3%    3.75us ± 2%     ~     (p=0.548 n=5+5)
    Map/Uint64Keys/SetMapIndex-4    6.13us ± 3%    6.09us ± 1%     ~     (p=0.746 n=5+5)

Change-Id: I5495d48948d8caf2d004a03ae1820ab5f8729670
Reviewed-on: https://go-review.googlesource.com/c/go/+/345486
Trust: Joe Tsai <joetsai@digital-static.net>
Run-TryBot: Joe Tsai <joetsai@digital-static.net>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2021-09-11 05:05:56 +00:00
.github
api net: reduce allocations for UDP send/recv on Windows 2021-08-16 23:57:10 +00:00
doc doc/asm: fix HTML markup 2021-09-10 17:15:37 +00:00
lib/time lib/time: fix RFC 6557 url 2021-08-15 02:18:46 +00:00
misc misc/wasm: enable ECMAScript strict mode 2021-09-03 19:56:09 +00:00
src reflect: optimize for maps with string keys 2021-09-11 05:05:56 +00:00
test cmd/compile: add support for Abs and Copysign intrinsics on riscv64 2021-09-10 10:45:59 +00:00
.gitattributes
.gitignore
AUTHORS A+C: update name 2021-06-01 17:08:12 +00:00
codereview.cfg
CONTRIBUTING.md
CONTRIBUTORS CONTRIBUTORS: update for the Go 1.17 release 2021-08-12 17:43:16 +00:00
LICENSE
PATENTS
README.md
SECURITY.md

The Go Programming Language

Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.

Gopher image Gopher image by Renee French, licensed under Creative Commons 3.0 Attributions license.

Our canonical Git repository is located at https://go.googlesource.com/go. There is a mirror of the repository at https://github.com/golang/go.

Unless otherwise noted, the Go source files are distributed under the BSD-style license found in the LICENSE file.

Download and Install

Binary Distributions

Official binary distributions are available at https://golang.org/dl/.

After downloading a binary release, visit https://golang.org/doc/install for installation instructions.

Install From Source

If a binary distribution is not available for your combination of operating system and architecture, visit https://golang.org/doc/install/source for source installation instructions.

Contributing

Go is the work of thousands of contributors. We appreciate your help!

To contribute, please read the contribution guidelines at https://golang.org/doc/contribute.html.

Note that the Go project uses the issue tracker for bug reports and proposals only. See https://golang.org/wiki/Questions for a list of places to ask questions about the Go language.