[dev.link] cmd/link/internal/loader: add 1-element object cache for use in toLocal
To speed up the loader.Loader.toLocal() method, cache the index of the most recently accessed object file and check that object's sym range in toLocal() before doing a full binary search over all object symbol ranges. This speeds up relink of kubernetes/hyperkube by about 2%, and improves compilebench (relative to the dev.link branch) by about 5%: name old time/op new time/op delta LinkCompiler 1.62s ± 8% 1.50s ± 9% -7.21% (p=0.000 n=20+19) LinkWithoutDebugCompiler 1.13s ± 8% 1.09s ±12% ~ (p=0.052 n=20+20) name old user-time/op new user-time/op delta LinkCompiler 1.94s ±18% 1.97s ±16% ~ (p=0.813 n=19+20) LinkWithoutDebugCompiler 1.15s ±16% 1.13s ±12% ~ (p=0.547 n=20+20) Change-Id: Id5a8a847b533858373c0462f03972d436eda6748 Reviewed-on: https://go-review.googlesource.com/c/go/+/204337Reviewed-by: Jeremy Faller <jeremy@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
Showing
Please register or sign in to comment