github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/internal/trace/v2/oldtrace.go (about)

     1  // Copyright 2024 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // This file implements conversion from old (Go 1.11–Go 1.21) traces to the Go
     6  // 1.22 format.
     7  //
     8  // Most events have direct equivalents in 1.22, at worst requiring arguments to
     9  // be reordered. Some events, such as GoWaiting need to look ahead for follow-up
    10  // events to determine the correct translation. GoSyscall, which is an
    11  // instantaneous event, gets turned into a 1 ns long pair of
    12  // GoSyscallStart+GoSyscallEnd, unless we observe a GoSysBlock, in which case we
    13  // emit a GoSyscallStart+GoSyscallEndBlocked pair with the correct duration
    14  // (i.e. starting at the original GoSyscall).
    15  //
    16  // The resulting trace treats the old trace as a single, large generation,
    17  // sharing a single evTable for all events.
    18  //
    19  // We use a new (compared to what was used for 'go tool trace' in earlier
    20  // versions of Go) parser for old traces that is optimized for speed, low memory
    21  // usage, and minimal GC pressure. It allocates events in batches so that even
    22  // though we have to load the entire trace into memory, the conversion process
    23  // shouldn't result in a doubling of memory usage, even if all converted events
    24  // are kept alive, as we free batches once we're done with them.
    25  //
    26  // The conversion process is lossless.
    27  
    28  package trace