Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add profiling with signals post #27

Merged
merged 1 commit into from
May 14, 2023

Conversation

javierhonduco
Copy link
Owner

Signed-off-by: Francisco Javier Honduvilla Coto [email protected]

Copy link
Collaborator

@ivoanjo ivoanjo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few notes :)

_posts/2023-2-10-profiling-with-signals.md Outdated Show resolved Hide resolved
_posts/2023-2-10-profiling-with-signals.md Outdated Show resolved Hide resolved
_posts/2023-2-10-profiling-with-signals.md Outdated Show resolved Hide resolved
_posts/2023-2-10-profiling-with-signals.md Outdated Show resolved Hide resolved

> This signal typically indicates the expiration of a timer that measures both CPU time used by the current process, and CPU time expended on behalf of the process by the system. Such a timer is used to implement code profiling facilities, hence the name of this signal.

We aren't using many CPU cycles in userspace as we have quickly been de-scheduled. The kernel might be using a bit of CPU for accounting purposes, but in any case it's probably very few CPU cycles, so it would take a very long time to ever a whole 2 seconds of kernel CPU time.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this example I don't think it would ever happen -- the process is sitting on a sleep so the only chance of the signal delivery happening is either before or after the sleep, which unless the CPU is running at 1MHz I don't think would happen :)

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a terrible example I agree! I think that the example below with the BPF loading where userspace uses no CPU but the kernel does might be a better thing to bring up. Will reword this :D

_posts/2023-2-10-profiling-with-signals.md Outdated Show resolved Hide resolved
_posts/2023-2-10-profiling-with-signals.md Outdated Show resolved Hide resolved
_posts/2023-2-10-profiling-with-signals.md Outdated Show resolved Hide resolved
_posts/2023-2-10-profiling-with-signals.md Outdated Show resolved Hide resolved

- [0] [signal-safety(7)](https://man7.org/linux/man-pages/man7/signal-safety.7.html)
- [1] Go's [`PrintStack`](https://pkg.go.dev/runtime/debug#PrintStack) and Ruby's [`Kernel#Caller`](https://ruby-doc.org/3.2.1/Kernel.html#method-i-caller).
- Seems like this issue was also found by Daniel. He wrote about it [in his website](https://dxuuu.xyz/bpf-go-pprof.html).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The clone system call also seems to potentially suffer from a similar issue, see async-profiler/async-profiler#97 , although there's workarounds for it.

@javierhonduco javierhonduco force-pushed the add-profiling-with-signals-post branch 2 times, most recently from 75118a9 to 623bef7 Compare May 14, 2023 17:48
Signed-off-by: Francisco Javier Honduvilla Coto <[email protected]>
@javierhonduco javierhonduco force-pushed the add-profiling-with-signals-post branch from 623bef7 to 6c86155 Compare May 14, 2023 17:48
@javierhonduco javierhonduco merged commit e385de2 into master May 14, 2023
@javierhonduco javierhonduco deleted the add-profiling-with-signals-post branch May 14, 2023 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants