]> Cypherpunks repositories - gostls13.git/commit
debug/buildinfo: reuse buffer in searchMagic
authorMichael Pratt <mpratt@google.com>
Fri, 26 Jul 2024 19:57:27 +0000 (15:57 -0400)
committerMichael Pratt <mpratt@google.com>
Wed, 31 Jul 2024 14:26:42 +0000 (14:26 +0000)
commiteea2e929fae6abbc1422f8ee26de02a4b7e4f8cd
treeb3fdc3ff8f69e79c3a2ca5923f7e5a34e9ef2e26
parentb6e81a51299f46b29ff7057dd043da8a42134eb0
debug/buildinfo: reuse buffer in searchMagic

Allocating a new buffer for each chunk in searchMagic is very
inefficient. Refactor reading to allow us to reuse the same buffer for
each iteration.

This reduces the runtime of `go version` on a 2.5GB non-Go binary from
~1s and ~25MB RSS to ~250ms and ~15MB RSS.

For #68592.

Change-Id: Idae5c2c9b3b8a7158d5cc7f2f008998be75fd7af
Reviewed-on: https://go-review.googlesource.com/c/go/+/601460
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
src/debug/buildinfo/buildinfo.go
src/debug/buildinfo/search_test.go