var countStartRE … var countRE … var heapHeaderRE … var heapSampleRE … var contentionSampleRE … var hexNumberRE … var growthHeaderRE … var fragmentationHeaderRE … var threadzStartRE … var threadStartRE … var spaceDigits … var hexPair … var oSpace … var cHex … var cHexRange … var cSpaceString … var cSpaceHex … var cSpaceAtOffset … var cPerm … var procMapsRE … var briefMapsRE … var logInfoRE … func isSpaceOrComment(line string) bool { … } // parseGoCount parses a Go count profile (e.g., threadcreate or // goroutine) and returns a new Profile. func parseGoCount(b []byte) (*Profile, error) { … } // remapLocationIDs ensures there is a location for each address // referenced by a sample, and remaps the samples to point to the new // location ids. func (p *Profile) remapLocationIDs() { … } func (p *Profile) remapFunctionIDs() { … } // remapMappingIDs matches location addresses with existing mappings // and updates them appropriately. This is O(N*M), if this ever shows // up as a bottleneck, evaluate sorting the mappings and doing a // binary search, which would make it O(N*log(M)). func (p *Profile) remapMappingIDs() { … } var cpuInts … func get32l(b []byte) (uint64, []byte) { … } func get32b(b []byte) (uint64, []byte) { … } func get64l(b []byte) (uint64, []byte) { … } func get64b(b []byte) (uint64, []byte) { … } // parseCPU parses a profilez legacy profile and returns a newly // populated Profile. // // The general format for profilez samples is a sequence of words in // binary format. The first words are a header with the following data: // // 1st word -- 0 // 2nd word -- 3 // 3rd word -- 0 if a c++ application, 1 if a java application. // 4th word -- Sampling period (in microseconds). // 5th word -- Padding. func parseCPU(b []byte) (*Profile, error) { … } // cpuProfile returns a new Profile from C++ profilez data. // b is the profile bytes after the header, period is the profiling // period, and parse is a function to parse 8-byte chunks from the // profile in its native endianness. func cpuProfile(b []byte, period int64, parse func(b []byte) (uint64, []byte)) (*Profile, error) { … } func cleanupDuplicateLocations(p *Profile) { … } // parseCPUSamples parses a collection of profilez samples from a // profile. // // profilez samples are a repeated sequence of stack frames of the // form: // // 1st word -- The number of times this stack was encountered. // 2nd word -- The size of the stack (StackSize). // 3rd word -- The first address on the stack. // ... // StackSize + 2 -- The last address on the stack // // The last stack trace is of the form: // // 1st word -- 0 // 2nd word -- 1 // 3rd word -- 0 // // Addresses from stack traces may point to the next instruction after // each call. Optionally adjust by -1 to land somewhere on the actual // call (except for the leaf, which is not a call). func parseCPUSamples(b []byte, parse func(b []byte) (uint64, []byte), adjust bool, p *Profile) ([]byte, map[uint64]*Location, error) { … } // parseHeap parses a heapz legacy or a growthz profile and // returns a newly populated Profile. func parseHeap(b []byte) (p *Profile, err error) { … } func parseHeapHeader(line string) (sampling string, period int64, hasAlloc bool, err error) { … } // parseHeapSample parses a single row from a heap profile into a new Sample. func parseHeapSample(line string, rate int64, sampling string, includeAlloc bool) (value []int64, blocksize int64, addrs []uint64, err error) { … } // parseHexAddresses extracts hex numbers from a string, attempts to convert // each to an unsigned 64-bit number and returns the resulting numbers as a // slice, or an error if the string contains hex numbers which are too large to // handle (which means a malformed profile). func parseHexAddresses(s string) ([]uint64, error) { … } // scaleHeapSample adjusts the data from a heapz Sample to // account for its probability of appearing in the collected // data. heapz profiles are a sampling of the memory allocations // requests in a program. We estimate the unsampled value by dividing // each collected sample by its probability of appearing in the // profile. heapz v2 profiles rely on a poisson process to determine // which samples to collect, based on the desired average collection // rate R. The probability of a sample of size S to appear in that // profile is 1-exp(-S/R). func scaleHeapSample(count, size, rate int64) (int64, int64) { … } // parseContention parses a mutex or contention profile. There are 2 cases: // "--- contentionz " for legacy C++ profiles (and backwards compatibility) // "--- mutex:" or "--- contention:" for profiles generated by the Go runtime. func parseContention(b []byte) (*Profile, error) { … } // parseContentionSample parses a single row from a contention profile // into a new Sample. func parseContentionSample(line string, period, cpuHz int64) (value []int64, addrs []uint64, err error) { … } // parseThread parses a Threadz profile and returns a new Profile. func parseThread(b []byte) (*Profile, error) { … } // parseThreadSample parses a symbolized or unsymbolized stack trace. // Returns the first line after the traceback, the sample (or nil if // it hits a 'same-as-previous' marker) and an error. func parseThreadSample(s *bufio.Scanner) (nextl string, addrs []uint64, err error) { … } // parseAdditionalSections parses any additional sections in the // profile, ignoring any unrecognized sections. func parseAdditionalSections(s *bufio.Scanner, p *Profile) error { … } // ParseProcMaps parses a memory map in the format of /proc/self/maps. // ParseMemoryMap should be called after setting on a profile to // associate locations to the corresponding mapping based on their // address. func ParseProcMaps(rd io.Reader) ([]*Mapping, error) { … } func parseProcMapsFromScanner(s *bufio.Scanner) ([]*Mapping, error) { … } // removeLoggingInfo detects and removes log prefix entries generated // by the glog package. If no logging prefix is detected, the string // is returned unmodified. func removeLoggingInfo(line string) string { … } // ParseMemoryMap parses a memory map in the format of // /proc/self/maps, and overrides the mappings in the current profile. // It renumbers the samples and locations in the profile correspondingly. func (p *Profile) ParseMemoryMap(rd io.Reader) error { … } // ParseMemoryMapFromScanner parses a memory map in the format of // /proc/self/maps or a variety of legacy format, and overrides the // mappings in the current profile. It renumbers the samples and // locations in the profile correspondingly. func (p *Profile) ParseMemoryMapFromScanner(s *bufio.Scanner) error { … } func parseMappingEntry(l string) (*Mapping, error) { … } var memoryMapSentinels … // isMemoryMapSentinel returns true if the string contains one of the // known sentinels for memory map information. func isMemoryMapSentinel(line string) bool { … } func (p *Profile) addLegacyFrameInfo() { … } var heapzSampleTypes … var contentionzSampleTypes … func isProfileType(p *Profile, types [][]string) bool { … } var allocRxStr … var allocSkipRxStr … var cpuProfilerRxStr … var lockRxStr …