Skip to content

Add unwind information in huf_decompress_amd64.S #4367

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

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

al13n321
Copy link

@al13n321 al13n321 commented Apr 17, 2025

These two asm functions clobber rbp register (aka omit frame pointer), but didn't provide stack unwinding information. So stack traces in profilers and debuggers couldn't go past these functions. This PR adds the unwind information, in a straightforward way.

I tested it with one profiler (ClickHouse's built-in query profiler, uses libunwind) and one debugger (https://github.com/al13n321/nnd), both managed to unwind through this function with this fix.

@facebook-github-bot
Copy link

Hi @al13n321!

Thank you for your pull request.

We require contributors to sign our Contributor License Agreement, and yours needs attention.

You currently have a record in our system, but the CLA is no longer valid, and will need to be resubmitted.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@al13n321
Copy link
Author

Example of profiler output before the fix (truncated stack traces in the left half):
before

After the fix (no-longer-truncated zstd stack traces in the right half):
after

@al13n321
Copy link
Author

al13n321 commented Apr 17, 2025

Btw, I'm confused: you guys at Meta use profilers (I used to use strobelight a lot), and zstd decompression probably takes a good fraction of cpu time in a lot of Meta software. Surely many people would notice if stack unwinding doesn't work well on zstd decompression? Why wasn't this already fixed ages ago? I'm probably missing something.

@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@Cyan4973
Copy link
Contributor

cc @terrelln

@embg
Copy link
Contributor

embg commented Jun 6, 2025

I am a big fan of this change. @MatzeB and I were just chatting about this issue a few weeks ago. This would be a great improvement IMO.

@MatzeB
Copy link

MatzeB commented Jun 6, 2025

I mentioned a while ago that we need frame pointers (aka rbp) to be setup for the profilers in our company. For all I know our profiling tools don't interpret unwind tables for performance reasons, so this change in itself won't help our setup. Of course adding proper unwind table information is a great idea regardless.

@Cyan4973
Copy link
Contributor

Cyan4973 commented Jun 6, 2025

Sounds good @embg !
I wanted @terrelln to have a look at it, because it changes the assembly source code.

Also there were a few test failures blocking this merge,
but one of them is unclear (it might just be a CI issue),
and the other one seems to happen in a different file, which has likely been fixed since.
I suspect a rebase of this PR on latest dev branch would be enough to clean these test errors.

@al13n321
Copy link
Author

al13n321 commented Jun 8, 2025

Rebased.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants