diff options
| author | Martin Möhrmann <moehrmann@google.com> | 2018-01-28 19:46:57 +0100 |
|---|---|---|
| committer | Brad Fitzpatrick <bradfitz@golang.org> | 2018-02-21 00:31:21 +0000 |
| commit | 8999b1d6c9be053f0e8c07ac3516eef7dc8a1830 (patch) | |
| tree | 7c19fb7ec42d763c7c7a2eb069ba9d18da9bc4f4 /src/runtime/malloc.go | |
| parent | b43ebce59b0eabe10ea2a1950c7173ed029cd093 (diff) | |
| download | go-8999b1d6c9be053f0e8c07ac3516eef7dc8a1830.tar.xz | |
runtime: shorten reflect.unsafe_New call chain
reflect.unsafe_New is an often called function according
to profiling in a large production environment.
Since newobject is not inlined currently there
is call overhead that can be avoided by calling
mallocgc directly.
name old time/op new time/op delta
New 32.4ns ± 2% 29.8ns ± 1% -8.03% (p=0.000 n=19+20)
Change-Id: I572e4be830ed8e5c0da555dc3a8864c8363112be
Reviewed-on: https://go-review.googlesource.com/95015
Reviewed-by: Austin Clements <austin@google.com>
Diffstat (limited to 'src/runtime/malloc.go')
| -rw-r--r-- | src/runtime/malloc.go | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/runtime/malloc.go b/src/runtime/malloc.go index 299add4b35..ecbae721dd 100644 --- a/src/runtime/malloc.go +++ b/src/runtime/malloc.go @@ -918,7 +918,7 @@ func newobject(typ *_type) unsafe.Pointer { //go:linkname reflect_unsafe_New reflect.unsafe_New func reflect_unsafe_New(typ *_type) unsafe.Pointer { - return newobject(typ) + return mallocgc(typ.size, typ, true) } // newarray allocates an array of n elements of type typ. |
