[go] cmd/link: avoid per-comparison loader calls in STYPE sort in dodata

0 views
Skip to first unread message

Gopher Robot (Gerrit)

unread,
Apr 14, 2026, 6:48:50 PM (16 hours ago) Apr 14
to Pierre Gimalac, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Ian Lance Taylor, Mark Freeman, David Chase, Cherry Mui, golang...@luci-project-accounts.iam.gserviceaccount.com, Michael Hudson-Doyle, Russ Cox, golang-co...@googlegroups.com

Gopher Robot submitted the change

Change information

Commit message:
cmd/link: avoid per-comparison loader calls in STYPE sort in dodata

The sort comparison function for STYPE symbols calls ldr.IsItab (which
dispatches through the loader into packed object file data) twice per
comparison and looks up a map for the type string on every call.

Pre-compute isItab, isTypelink, and typeStr into the symNameSize struct
alongside the existing sz field in a single linear pass before the sort.
The comparison function and the post-sort boundary loops then do only
struct field reads.

Measured the `dodata` phase when linking a large CGO binary
(github.com/DataDog/datadog-agent/cmd/agent) using `-benchmark=cpu`:

go1.26.2: 207ms, 205ms, 206ms
tip: 714ms, 702ms, 700ms
tip+fix: 325ms, 325ms, 333ms

Fixes #78642.
Change-Id: I4c1e3acc1c57b8c31441e6b6485debb0cce9b197
Reviewed-by: Ian Lance Taylor <ia...@golang.org>
Reviewed-by: Mark Freeman <markf...@google.com>
Auto-Submit: Ian Lance Taylor <ia...@golang.org>
Reviewed-by: David Chase <drc...@google.com>
Files:
  • M src/cmd/link/internal/ld/data.go
Change size: S
Delta: 1 file changed, 25 insertions(+), 16 deletions(-)
Branch: refs/heads/master
Submit Requirements:
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I4c1e3acc1c57b8c31441e6b6485debb0cce9b197
Gerrit-Change-Number: 765700
Gerrit-PatchSet: 3
Gerrit-Owner: Pierre Gimalac <pierre....@datadoghq.com>
Gerrit-Reviewer: David Chase <drc...@google.com>
Gerrit-Reviewer: Gopher Robot <go...@golang.org>
Gerrit-Reviewer: Ian Lance Taylor <ia...@golang.org>
Gerrit-Reviewer: Mark Freeman <markf...@google.com>
Gerrit-Reviewer: Michael Hudson-Doyle <michael...@canonical.com>
Gerrit-Reviewer: Russ Cox <r...@golang.org>
Gerrit-CC: Cherry Mui <cher...@google.com>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages