]> Cypherpunks repositories - gostls13.git/commit
runtime: faster version of findfunc
authorKeith Randall <khr@golang.org>
Sun, 28 Dec 2014 03:26:40 +0000 (19:26 -0800)
committerKeith Randall <khr@golang.org>
Wed, 7 Jan 2015 21:24:21 +0000 (21:24 +0000)
commit63116de558b472c437df186d6bf87e163f674ea2
treeb3a997702dd8737db1bbde6408fd1ce6639333ef
parentaf7ca8dce4991860263d5e0d0322461cfd00c599
runtime: faster version of findfunc

Use a lookup table to find the function which contains a pc.  It is
faster than the old binary search.  findfunc is used primarily for
stack copying and garbage collection.

benchmark              old ns/op     new ns/op     delta
BenchmarkStackCopy     294746596     255400980     -13.35%

(findfunc is one of several tasks done by stack copy, the findfunc
time itself is about 2.5x faster.)

The lookup table is built at link time.  The table grows the binary
size by about 0.5% of the text segment.

We impose a lower limit of 16 bytes on any function, which should not
have much of an impact.  (The real constraint required is <=256
functions in every 4096 bytes, but 16 bytes/function is easier to
implement.)

Change-Id: Ic315b7a2c83e1f7203cd2a50e5d21a822e18fdca
Reviewed-on: https://go-review.googlesource.com/2097
Reviewed-by: Russ Cox <rsc@golang.org>
src/cmd/ld/data.c
src/cmd/ld/lib.h
src/cmd/ld/pcln.c
src/cmd/ld/pobj.c
src/runtime/symtab.go