Commit 8999b1d6 authored by Martin Möhrmann's avatar Martin Möhrmann Committed by Brad Fitzpatrick

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/95015Reviewed-by: 's avatarAustin Clements <austin@google.com>
parent b43ebce5
......@@ -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.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment