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

Improve GC stack scanning #4550

Open
aykevl opened this issue Oct 25, 2024 · 0 comments
Open

Improve GC stack scanning #4550

aykevl opened this issue Oct 25, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@aykevl
Copy link
Member

aykevl commented Oct 25, 2024

Right now, the GC will scan only the in-use part of the stack of the current goroutine, but for every other goroutine it will scan the entire stack (not just the part that contains any data).

This can be fixed for the precise GC in the following way:

  • Use a special "layout" value when allocating a stack (that would otherwise not be used), and detecting this value during the scan.
  • Find the *task.Task struct that it belongs to (how? Maybe by putting a pointer somewhere at a fixed point back to *task.Task?)
  • Scanning from the sp address in the *task.Task struct up to the highest address. (This needs some adjusting for WebAssembly, where there are in fact two stacks that need to be scanned per paused goroutine).

If there are multiple goroutines in a running program, I think this will significantly improve GC performance.

@aykevl aykevl added the enhancement New feature or request label Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant