]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: remove allocfreetrace
authorMichael Anthony Knyszek <mknyszek@google.com>
Wed, 24 Apr 2024 15:50:43 +0000 (15:50 +0000)
committerGopher Robot <gobot@golang.org>
Wed, 8 May 2024 17:44:56 +0000 (17:44 +0000)
allocfreetrace prints all allocations and frees to stderr. It's not
terribly useful because it has a really huge overhead, making it not
feasible to use except for the most trivial programs. A follow-up CL
will replace it with something that is both more thorough and also lower
overhead.

Change-Id: I1d668fee8b6aaef5251a5aea3054ec2444d75eb6
Reviewed-on: https://go-review.googlesource.com/c/go/+/583376
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Auto-Submit: Michael Knyszek <mknyszek@google.com>

src/runtime/arena.go
src/runtime/extern.go
src/runtime/malloc.go
src/runtime/mgc.go
src/runtime/mgcsweep.go
src/runtime/mprof.go
src/runtime/runtime1.go

index bb88ed053dc2bde0514f21008c91c2375ba60506..47b131466c80c8d2d690f4c8a2b11b2e33a277cb 100644 (file)
@@ -828,10 +828,6 @@ func newUserArenaChunk() (unsafe.Pointer, *mspan) {
        }
 
        if debug.malloc {
-               if debug.allocfreetrace != 0 {
-                       tracealloc(unsafe.Pointer(span.base()), userArenaChunkBytes, nil)
-               }
-
                if inittrace.active && inittrace.id == getg().goid {
                        // Init functions are executed sequentially in a single goroutine.
                        inittrace.bytes += uint64(userArenaChunkBytes)
index 63950c3b5f0462b22f00d91629bf1ca1c3df81a5..833019a7b46bbaec86fd4a42142a57e8bdf92d54 100644 (file)
@@ -35,9 +35,6 @@ time.
 The GODEBUG variable controls debugging variables within the runtime.
 It is a comma-separated list of name=val pairs setting these named variables:
 
-       allocfreetrace: setting allocfreetrace=1 causes every allocation to be
-       profiled and a stack trace printed on each object's allocation and free.
-
        clobberfree: setting clobberfree=1 causes the garbage collector to
        clobber the memory content of an object with bad content when it frees
        the object.
index 48cace9171b1155719845b6ea79064c20e0c2e27..a572900eb784923ada03bf08270f893593dd405a 100644 (file)
@@ -1261,10 +1261,6 @@ func mallocgc(size uintptr, typ *_type, needzero bool) unsafe.Pointer {
        }
 
        if debug.malloc {
-               if debug.allocfreetrace != 0 {
-                       tracealloc(x, size, typ)
-               }
-
                if inittrace.active && inittrace.id == getg().goid {
                        // Init functions are executed sequentially in a single goroutine.
                        inittrace.bytes += uint64(fullSize)
index 83afd55c47cd9d4f6f19ddca885abef00e80e509..1316af72baf1d4153ce31a9f6418d747114e5993 100644 (file)
@@ -1510,10 +1510,6 @@ func gcMarkWorkAvailable(p *p) bool {
 // All gcWork caches must be empty.
 // STW is in effect at this point.
 func gcMark(startTime int64) {
-       if debug.allocfreetrace > 0 {
-               tracegc()
-       }
-
        if gcphase != _GCmarktermination {
                throw("in gcMark expecting to see gcphase as _GCmarktermination")
        }
index 5670b1b8d5550fb2bcf558ec4a39069573b7388c..da66bfa59693b78e85c9b75912bee05e807fa221 100644 (file)
@@ -608,17 +608,13 @@ func (sl *sweepLocked) sweep(preserve bool) bool {
                spanHasNoSpecials(s)
        }
 
-       if debug.allocfreetrace != 0 || debug.clobberfree != 0 || raceenabled || msanenabled || asanenabled {
-               // Find all newly freed objects. This doesn't have to
-               // efficient; allocfreetrace has massive overhead.
+       if debug.clobberfree != 0 || raceenabled || msanenabled || asanenabled {
+               // Find all newly freed objects.
                mbits := s.markBitsForBase()
                abits := s.allocBitsForIndex(0)
                for i := uintptr(0); i < uintptr(s.nelems); i++ {
                        if !mbits.isMarked() && (abits.index < uintptr(s.freeindex) || abits.isMarked()) {
                                x := s.base() + i*s.elemsize
-                               if debug.allocfreetrace != 0 {
-                                       tracefree(unsafe.Pointer(x), size)
-                               }
                                if debug.clobberfree != 0 {
                                        clobberfree(unsafe.Pointer(x), size)
                                }
index 87eed8d1ddba5fcd4c71708d4e6c3276b6897897..26b7d78283ed14c5e621fed811233c4b556161a1 100644 (file)
@@ -1459,61 +1459,3 @@ func Stack(buf []byte, all bool) int {
        }
        return n
 }
-
-// Tracing of alloc/free/gc.
-
-var tracelock mutex
-
-func tracealloc(p unsafe.Pointer, size uintptr, typ *_type) {
-       lock(&tracelock)
-       gp := getg()
-       gp.m.traceback = 2
-       if typ == nil {
-               print("tracealloc(", p, ", ", hex(size), ")\n")
-       } else {
-               print("tracealloc(", p, ", ", hex(size), ", ", toRType(typ).string(), ")\n")
-       }
-       if gp.m.curg == nil || gp == gp.m.curg {
-               goroutineheader(gp)
-               pc := getcallerpc()
-               sp := getcallersp()
-               systemstack(func() {
-                       traceback(pc, sp, 0, gp)
-               })
-       } else {
-               goroutineheader(gp.m.curg)
-               traceback(^uintptr(0), ^uintptr(0), 0, gp.m.curg)
-       }
-       print("\n")
-       gp.m.traceback = 0
-       unlock(&tracelock)
-}
-
-func tracefree(p unsafe.Pointer, size uintptr) {
-       lock(&tracelock)
-       gp := getg()
-       gp.m.traceback = 2
-       print("tracefree(", p, ", ", hex(size), ")\n")
-       goroutineheader(gp)
-       pc := getcallerpc()
-       sp := getcallersp()
-       systemstack(func() {
-               traceback(pc, sp, 0, gp)
-       })
-       print("\n")
-       gp.m.traceback = 0
-       unlock(&tracelock)
-}
-
-func tracegc() {
-       lock(&tracelock)
-       gp := getg()
-       gp.m.traceback = 2
-       print("tracegc()\n")
-       // running on m->g0 stack; show all non-g0 goroutines
-       tracebackothers(gp)
-       print("end tracegc\n")
-       print("\n")
-       gp.m.traceback = 0
-       unlock(&tracelock)
-}
index 5b37d23e90cf023e6f7e13704590860ec3df0011..dd19242cb45c65ad21063deb5f292c8e8267081b 100644 (file)
@@ -334,10 +334,9 @@ var debug struct {
        // debug.malloc is used as a combined debug check
        // in the malloc function and should be set
        // if any of the below debug options is != 0.
-       malloc         bool
-       allocfreetrace int32
-       inittrace      int32
-       sbrk           int32
+       malloc    bool
+       inittrace int32
+       sbrk      int32
 
        panicnil atomic.Int32
 
@@ -354,7 +353,6 @@ var debug struct {
 
 var dbgvars = []*dbgVar{
        {name: "adaptivestackstart", value: &debug.adaptivestackstart},
-       {name: "allocfreetrace", value: &debug.allocfreetrace},
        {name: "asyncpreemptoff", value: &debug.asyncpreemptoff},
        {name: "asynctimerchan", atomic: &debug.asynctimerchan},
        {name: "cgocheck", value: &debug.cgocheck},
@@ -425,7 +423,7 @@ func parsedebugvars() {
        // apply environment settings
        parsegodebug(godebug, nil)
 
-       debug.malloc = (debug.allocfreetrace | debug.inittrace | debug.sbrk) != 0
+       debug.malloc = (debug.inittrace | debug.sbrk) != 0
 
        setTraceback(gogetenv("GOTRACEBACK"))
        traceback_env = traceback_cache