pkg / profile

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

How to profile loading of libraries ? #47

Closed fxfactorial closed 5 years ago

fxfactorial commented 5 years ago

Fantastic tool.

One thing, say I have a binary that is loading slowly from a massive amount of imports that may possibly be having side effects upon code being loaded.

I don't see how to use profile here because I put defer profile.Start().Stop() at the beginning of main but that doesn't capture the loading/code execution of library code.

thank you

davecheney commented 5 years ago

This is not possible with the profiling built into go because the text segment of the binary is demand paged into memory.

If you are on Linux I suggest perf(1).

On 12 Sep 2019, at 14:34, Edgar Aroutiounian notifications@github.com wrote:

Fantastic tool.

One thing, say I have a binary that is loading slowly from a massive amount of imports that may possibly be having side effects upon code being loaded.

I don't see how to use profile here because I put defer profile.Start().Stop() at the beginning of main but that doesn't capture the loading/code execution of library code.

thank you

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

davecheney commented 5 years ago

Closing. Answered.

fxfactorial commented 5 years ago

@davecheney thank you for quick answer (I am mostly working on OS X but will look at perf(1)). Side question, there isn't an equvialent in go for like

__attribute__((constructor))

and have profiling code setup there?

davecheney commented 5 years ago

Nope. Nothing like that. Please try go-nuts or slack for General go questions.

On 12 Sep 2019, at 14:47, Edgar Aroutiounian notifications@github.com wrote:

@davecheney thank you for quick answer. Side question, there isn't an equvialent in go for like

attribute((constructor)) ?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.