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

lang: Make stack frames slimmer on ATA creation #3065

Merged

Conversation

andreisilviudragnea
Copy link
Contributor

@andreisilviudragnea andreisilviudragnea commented Jul 2, 2024

Initializing many associated token accounts in the same instruction can result in too large stack frames at compile time:

    #[account(
        init,
        payer = payer,
        associated_token::authority = system_program,
        associated_token::mint = mint,
    )]
Error: Function _ZN137_$LT$pda_derivation..AssociatedTokenResolution$u20$as$u20$anchor_lang..Accounts$LT$pda_derivation..AssociatedTokenResolutionBumps$GT$$GT$12try_accounts17hddc314f570fb4fb5E Stack offset of 7696 exceeded max offset of 4096 by 3600 bytes, please minimize large stack variables

The problem has been fixed similar to #2913 by inlining local variables created while generating associated token account creation code.

Copy link

vercel bot commented Jul 2, 2024

@andreisilviudragnea is attempting to deploy a commit to the coral-xyz Team on Vercel.

A member of the Team first needs to authorize it.

@acheroncrypto acheroncrypto added lang performance Performance related issues/PRs labels Jul 2, 2024
Copy link
Collaborator

@acheroncrypto acheroncrypto left a comment

Choose a reason for hiding this comment

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

This is an area we'd like to improve, so thank you for the PR!

Please see the comments.

lang/syn/src/codegen/accounts/constraints.rs Outdated Show resolved Hide resolved
spl/src/associated_token.rs Outdated Show resolved Hide resolved
tests/pda-derivation/programs/pda-derivation/src/lib.rs Outdated Show resolved Hide resolved
@andreisilviudragnea andreisilviudragnea changed the title Make stack frames slimmer on ATA creation lang: Make stack frames slimmer on ATA creation Jul 2, 2024
Copy link
Collaborator

@acheroncrypto acheroncrypto left a comment

Choose a reason for hiding this comment

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

Looks great now, thanks!

@acheroncrypto acheroncrypto merged commit 5727865 into coral-xyz:master Jul 3, 2024
32 of 48 checks passed
@andreisilviudragnea andreisilviudragnea deleted the slim-stack-frame branch July 4, 2024 06:47
@andreisilviudragnea
Copy link
Contributor Author

@acheroncrypto When will a new Anchor version be released? This fix is quite important for me.

@acheroncrypto
Copy link
Collaborator

Not sure, but we might need to make a patch release depending on the resolution of #3044.

Do you publish your crates? If not, you can just depend on the git version until the next release.

@andreisilviudragnea
Copy link
Contributor Author

andreisilviudragnea commented Aug 20, 2024

@acheroncrypto When approximately will a new Anchor version be released?

Depending on git versions for dependencies can sometimes be seen as an unsafe habit. I see there is very active development on master branch, so I expect it to take some time.

@acheroncrypto
Copy link
Collaborator

@acheroncrypto When approximately will a new Anchor version be released?

~3 weeks

Depending on git versions for dependencies can sometimes be seen as an unsafe habit. I see there is very active development on master branch, so I expect it to take some time.

This PR was merged slightly after the last release, so there won't be many changes if you depend on this PR's commit hash 5727865.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lang performance Performance related issues/PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants