Skip to content

Profiling - #125

Merged
Amjad50 merged 13 commits into
masterfrom
profiling
Jul 27, 2025
Merged

Profiling#125
Amjad50 merged 13 commits into
masterfrom
profiling

Conversation

@Amjad50

@Amjad50 Amjad50 commented Jul 26, 2025

Copy link
Copy Markdown
Owner

Summary

Add profiling support for the kernel through qemu and qmp protocl

This works by attacking to qmp socket and fetching the current stack by using gdb commands through qemu.
Then we get a stack.folded file where we can generate flamegraph with or use it in https://www.speedscope.app/

This now will make profiling and optimizing the OS so much simpler

Related issue

  • Kernel Profiling #118 (even though this wasn't the intended way, but this works so well)
  • Userspace profiling #119 (this kinda implements userspace profiling as well, but I don't like it so much so I won't make it finished)
    • actually, turns out, we can implement very robust and nice userspace profiling, I would say userspace profiling is also done, but maybe for the future, let's make a profiler in our kernel that will profile userspace processes only.

Changes

  • Add xtask profile command where it will attach to ./qmp-socket that was created by xtask --profile run and gives
    a summary or stack.folded (with -o parameter)
  • Right now we made xtask run as --release by default because tracing require a bit of performance.
  • Fixed unwinding in rust

Checklist

  • The changes are tested and works as expected (mention if not)
  • Tests if applicable (new features, regression tests, etc...)
  • Documentation
  • Needed README changes

Amjad50 added 5 commits July 26, 2025 18:13
Signed-off-by: Amjad Alsharafi <26300843+Amjad50@users.noreply.github.com>
For some reason the stack trace produced is not accurate

Signed-off-by: Amjad Alsharafi <26300843+Amjad50@users.noreply.github.com>
Signed-off-by: Amjad Alsharafi <26300843+Amjad50@users.noreply.github.com>
Signed-off-by: Amjad Alsharafi <26300843+Amjad50@users.noreply.github.com>
Signed-off-by: Amjad Alsharafi <26300843+Amjad50@users.noreply.github.com>
Amjad50 added 3 commits July 27, 2025 08:44
Updated deprecated option in `.vscode/launch.json` for debugging.

Signed-off-by: Amjad Alsharafi <26300843+Amjad50@users.noreply.github.com>
The issue was that we were getting the `vma_base` from the sections and not the segments.

Its just a small change, but massive impact

Signed-off-by: Amjad Alsharafi <26300843+Amjad50@users.noreply.github.com>
…hing programs

This now works really nicely, just a few improvements to performance,
but other than that, this is so good.

Signed-off-by: Amjad Alsharafi <26300843+Amjad50@users.noreply.github.com>
Amjad50 added 3 commits July 27, 2025 13:15
Signed-off-by: Amjad Alsharafi <26300843+Amjad50@users.noreply.github.com>
Signed-off-by: Amjad Alsharafi <26300843+Amjad50@users.noreply.github.com>
Signed-off-by: Amjad Alsharafi <26300843+Amjad50@users.noreply.github.com>
@Amjad50
Amjad50 enabled auto-merge July 27, 2025 05:16
@Amjad50
Amjad50 disabled auto-merge July 27, 2025 05:17
Amjad50 added 2 commits July 27, 2025 13:57
Leaking is safe :D

Signed-off-by: Amjad Alsharafi <26300843+Amjad50@users.noreply.github.com>
Signed-off-by: Amjad Alsharafi <26300843+Amjad50@users.noreply.github.com>
@Amjad50
Amjad50 enabled auto-merge July 27, 2025 06:06
@Amjad50
Amjad50 merged commit 4a7a8f5 into master Jul 27, 2025
4 checks passed
@Amjad50
Amjad50 deleted the profiling branch July 27, 2025 06:08
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.

1 participant