1

In this article: https://www.datadoghq.com/blog/engineering/profiling-improvements-in-go-1-18/. Below word confusing me:reporting 20 CPU cores being used by top, the expected signal rate should have been 2,000 signals per second. However, the resulting profile only contained an average of 240 stack traces per second. .

What i am confusing is that in func runtime.SetCPUProfileRate, only set the current thread profileHz to 100. And I know that in linux, the signal is randomly pick one thread to execute. So thread which profileHz is not zero will only receive about 2000 / 20 = 100 signal percond. So the average stack traces is about 100 per second.

Why this article said that the stack trace will produce 240 and even more stack traces per second?

jie yang
  • 21
  • 2

1 Answers1

1

It seems that go add sigmask for all thread in init:

// minitSignalStack is called when initializing a new m to set the
// alternate signal stack. If the alternate signal stack is not set
// for the thread (the normal case) then set the alternate signal
// stack to the gsignal stack. If the alternate signal stack is set
// for the thread (the case when a non-Go thread sets the alternate
// signal stack and then calls a Go function) then set the gsignal
// stack to the alternate signal stack. We also set the alternate
// signal stack to the gsignal stack if cgo is not used (regardless
// of whether it is already set). Record which choice was made in
// newSigstack, so that it can be undone in unminit.
func minitSignalStack() {

so only the thread that start pprof can receive sigprof signal.

jie yang
  • 21
  • 2