pkg / profile

Simple profiling for Go
BSD 2-Clause "Simplified" License
2k stars 122 forks source link

10 byte profile file can't be opened #57

Closed thnk2wn closed 3 years ago

thnk2wn commented 3 years ago

After profiling I get a 10 byte file (cpu.pprof.zip) that when read produces:

Tried both:

defer profile.Start(profile.ProfilePath(os.Getenv("HOME"))).Stop()

as well as:

p := profile.Start(profile.ProfilePath(os.Getenv("HOME")), profile.NoShutdownHook)
// ...
p.Stop()

As of 3704c8d23324a3fc0771ad2c1cef0aa4e9459f6f on macOS Big Sur 11.1.

With the shutdown hook I saw the library was intercepting shutdown to stop profiling. Without it I see my code called to .Stop().

Troubleshooting ideas?

Thanks for your work.

davecheney commented 3 years ago

How much work is your program doing between starting and stopping the profile?

thnk2wn commented 3 years ago

@davecheney I ran the API app for about 5 minutes and made several requests over HTTP and web sockets that hit PostgreSQL, Elastic Search, Redis, 3rd party APIs, S3, etc.

davecheney commented 3 years ago

Seems reasonable; how are you stopping the program, or the profile?

thnk2wn commented 3 years ago

SIGINT with Ctrl+C. File was 0 bytes during execution and 10 bytes at the end.

On January 16, 2021, docker-desktop-robot notifications@github.com wrote:

Seems reasonable; how are you stopping the program, or the profile?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/pkg/profile/issues/57#issuecomment-761626616, or unsubscribe https://github.com/notifications/unsubscribe- auth/AAA5NUI2LPAVJRI3AG7YIA3S2HYM5ANCNFSM4WEIIRLQ.

davecheney commented 3 years ago

Can you reproduce the issue on a non big sur machine? Maybe try the trace profile not CPU profile. Perhaps pprof is broken on big sur

thnk2wn commented 3 years ago

For my needs https://github.com/gin-contrib/pprof worked but can maybe look into this more later. Thanks

davecheney commented 3 years ago

ok, no problem. I'll close this for the moment, please feel free to reopen it in the future.