Skip to content

Add unwind information in huf_decompress_amd64.S#4367

Merged
Cyan4973 merged 2 commits into
facebook:devfrom
ClickHouse:cfi
Jun 20, 2025
Merged

Add unwind information in huf_decompress_amd64.S#4367
Cyan4973 merged 2 commits into
facebook:devfrom
ClickHouse:cfi

Conversation

@al13n321

@al13n321 al13n321 commented Apr 17, 2025

Copy link
Copy Markdown
Contributor

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
Copy Markdown

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 cla@meta.com. Thanks!

@al13n321

Copy link
Copy Markdown
Contributor 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

al13n321 commented Apr 17, 2025

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown

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
Copy Markdown
Contributor

cc @terrelln

@embg

embg commented Jun 6, 2025

Copy link
Copy Markdown
Contributor

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

MatzeB commented Jun 6, 2025

Copy link
Copy Markdown

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

Cyan4973 commented Jun 6, 2025

Copy link
Copy Markdown
Contributor

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

al13n321 commented Jun 8, 2025

Copy link
Copy Markdown
Contributor Author

Rebased.

@Cyan4973
Cyan4973 merged commit 7eefc22 into facebook:dev Jun 20, 2025
101 checks passed
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