]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: batch allocations of Lsym
authorShahar Kohanim <skohanim@gmail.com>
Mon, 29 Feb 2016 14:46:18 +0000 (16:46 +0200)
committerBrad Fitzpatrick <bradfitz@golang.org>
Mon, 29 Feb 2016 17:32:11 +0000 (17:32 +0000)
Reduces best of 10 linking of cmd/go by ~5%

Change-Id: If673b877ee12595dae517d7eb48430451e5cadba
Reviewed-on: https://go-review.googlesource.com/20060
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/cmd/link/internal/ld/link.go
src/cmd/link/internal/ld/sym.go

index 73d23c6cf0a659e50648f579f845f4889a6bb6f0..5a02aca728fca70415e0190f2bd69d81c2684fd8 100644 (file)
@@ -158,6 +158,7 @@ type Link struct {
        Nhistfile  int32
        Filesyms   *LSym
        Moduledata *LSym
+       LSymBatch  []LSym
 }
 
 // The smallest possible offset from the hardware stack pointer to a local
index 099243442b6d0ed4d96923058113c2bfe9443084..5f31e59e09d19f3214dd6a4a746d4e5cc7eadd14 100644 (file)
@@ -157,8 +157,12 @@ func linknew(arch *LinkArch) *Link {
 }
 
 func linknewsym(ctxt *Link, symb string, v int) *LSym {
-       s := new(LSym)
-       *s = LSym{}
+       batch := ctxt.LSymBatch
+       if len(batch) == 0 {
+               batch = make([]LSym, 1000)
+       }
+       s := &batch[0]
+       ctxt.LSymBatch = batch[1:]
 
        s.Dynid = -1
        s.Plt = -1