I've now filed https://github.com/golang/go/issues/65328 to report this.

On Friday 3 March 2023 at 09:47:26 UTC Jochen Voss wrote:

> Hi Peter,
>
> Thanks again for looking into this, and for your help!
>
> You mention that the blog post was long ago.  I wonder whether the code to 
> write profile information is covered by the compatibility promise.  If so, 
> probably the legacy WriteHeapProfile function could be made to implement 
> the required code to keep this working.  Should a bug report be filed to 
> this effect? 
>
> Similarly, should a bug report be filed about the mistake you found in the 
> pprof package documentation?
>
> All the best,
> Jochen
> On Thursday, 2 March 2023 at 15:36:24 UTC peterGo wrote:
>
>> On Thursday, March 2, 2023 at 2:03:22 AM UTC-5 Jochen Voss wrote:
>>
>> Hi Peter,
>>
>> Thanks a lot, giving the "-alloc_space" option makes all the difference!  
>> With this option, it also works for me.
>>
>> I wonder whether it meant to be the way that you have to give this 
>> option.  Maybe something broke?  In the blog entry 
>> https://go.dev/blog/pprof they didn't need this option to get the 
>> profile output.
>>
>>
>> The Go blog post at https://go.dev/blog/pprof was written in 2011; it is 
>> now 2023. For up-to-date information, see the latest pprof package 
>> documentation at https://pkg.go.dev/runtime/pprof@latest.
>>
>> The pprof package documentation is incorrect: 
>>
>> To add equivalent [go test] profiling support to a standalone program, 
>> add code like the following to your main function:
>>
>>     // ...
>>     runtime.GC() // get up-to-date statistics
>>     if err := pprof.WriteHeapProfile(f); err != nil {
>>         log.Fatal("could not write memory profile: ", err)
>>     }
>>     // ...
>>
>> To obtain equivalent results, replace the above code with:
>>
>>     // ...
>>     runtime.GC() // get up-to-date statistics
>>     if allocs := pprof.Lookup("allocs"); allocs == nil {
>>         log.Fatal("could not lookup memory profile: ")
>>     } else if err := allocs.WriteTo(f, 0); err != nil {
>>
>>         log.Fatal("could not write memory profile: ", err)
>>     }
>>     // ...
>>
>> For your example,
>>
>> yyy.go: https://go.dev/play/p/epy4c3et1Io
>>
>> $ go build yyy.go && ./yyy
>> $ go tool pprof mem.prof
>> File: yyy
>> Type: alloc_space
>> Time: Mar 2, 2023 at 10:02am (EST)
>>
>> Entering interactive mode (type "help" for commands, "o" for options)
>> (pprof) top
>> Showing nodes accounting for 6975.42MB, 98.93% of 7050.77MB total
>> Dropped 62 nodes (cum <= 35.25MB)
>>
>> Showing top 10 nodes out of 18
>>       flat  flat%   sum%        cum   cum%
>>  3564.88MB 50.56% 50.56%  3564.88MB 50.56%  
>> golang.org/x/exp/slices.Insert[.. 
>> <http://golang.org/x/exp/slices.Insert%5B..>.] (inline)
>>  3122.14MB 44.28% 94.84%  3122.14MB 44.28%  
>> seehuhn.de/go/layout.(*Skip).Minus
>>   117.01MB  1.66% 96.50%   117.01MB  1.66%  
>> seehuhn.de/go/layout.(*Skip).Clone (inline)
>>   115.51MB  1.64% 98.14%  6919.54MB 98.14%  
>> seehuhn.de/go/layout.(*knuthPlassLineBreaker).Run
>>    52.89MB  0.75% 98.89%    65.63MB  0.93%  compress/flate.NewWriter
>>     2.50MB 0.035% 98.92%  6926.54MB 98.24%  
>> seehuhn.de/go/layout.(*Engine).EndParagraph
>>     0.50MB 0.0071% 98.93%  7050.27MB   100%  main.main
>>          0     0% 98.93%    65.63MB  0.93%  compress/flate.NewWriterDict
>>          0     0% 98.93%    65.63MB  0.93%  compress/zlib.(*Writer).Write
>>          0     0% 98.93%    65.63MB  0.93% 
>>  compress/zlib.(*Writer).writeHeader
>> (pprof) quit
>> $ 
>>
>> Peter
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/52a65cdb-afee-4101-9602-42c0d17a3088n%40googlegroups.com.

Reply via email to