Skip to content

Conversation

@LucasSte
Copy link
Collaborator

@LucasSte LucasSte commented Dec 2, 2025

In sBPFv3, we are giving 4096 bytes of stack for free, and only bumping the frame pointer if the function requires more than that.

This PR adjusts the SBF backend to do exactly that.

@LucasSte LucasSte changed the title [SOL] Use a relative bump for stack in sBPFv3. [SOL] Use a relative bump for stack in sBPFv3 Dec 3, 2025
@LucasSte LucasSte requested a review from Lichtso December 3, 2025 13:36
@LucasSte LucasSte marked this pull request as ready for review December 3, 2025 13:36
@Lichtso
Copy link
Collaborator

Lichtso commented Dec 3, 2025

This leaves a lot of usable stack space on the table. I think it would be better to always subtract 0x1000, no matter if it is larger, equal, smaller. It means a little bigger programs but a lot more usable stack space / allows requesting less stack in total.

@LucasSte
Copy link
Collaborator Author

LucasSte commented Dec 3, 2025

This leaves a lot of usable stack space on the table. I think it would be better to always subtract 0x1000, no matter if it is larger, equal, smaller. It means a little bigger programs but a lot more usable stack space / allows requesting less stack in total.

We always allocate the same amount of stack for all programs, right?

I did not take that approach because that would increase CU consumption, and people complain about that constantly. We could add the option for "stack management optimization" (which follows your suggestion) behind a feature flag. How does that sound?

@LucasSte LucasSte merged commit aa4803f into anza-xyz:solana-rustc/20.1-2025-02-13 Dec 4, 2025
10 checks passed
@LucasSte LucasSte deleted the rel-bump branch December 4, 2025 22:00
tomisetsu pushed a commit to tos-network/llvm-project that referenced this pull request Dec 6, 2025
tomisetsu added a commit to tos-network/llvm-project that referenced this pull request Dec 6, 2025
Upstream commits merged (already applied with TBF/TOS adaptations):
- aa4803f [SOL] Use a relative bump for stack in sBPFv3 (anza-xyz#181)
- 427d50d [SOL] Emit EM_BPF for SBPFv3 (anza-xyz#180)

These changes were previously cherry-picked and adapted for TBF/TOS naming
in commits f3c4c39, 77dcae2, 7864f44, and 209ddfa.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
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