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

Regularly collect fiber stack #9

Closed
ysbaddaden opened this issue Apr 18, 2024 · 2 comments · Fixed by #17
Closed

Regularly collect fiber stack #9

ysbaddaden opened this issue Apr 18, 2024 · 2 comments · Fixed by #17
Assignees
Labels
bug Something isn't working enhancement New feature or request

Comments

@ysbaddaden
Copy link
Owner

ysbaddaden commented Apr 18, 2024

The fiber stack collectors got disabled for some reason —probably when dealing with dead fiber stacks— but we must re-enable it to avoid sudden spikes to keep the allocated memory when we could recover some memory.

Stacks being kept per execution context, we might also keep stacks allocated in context A despite context B now spawning fibers, while context A doesn't do much anymore (leaking some memory). An alternative to that specific issue could be to have a single Stack Pool for the process, but one per execution context sounds more optimal (they should usually do the same thing, and thus roughly use the same stack space), while different contexts may keep larger stacks allocated, despite not needing that much.

I'll welcome nicer heuristics than the blunt "deallocate half the stacks every 5 seconds".

@ysbaddaden ysbaddaden added bug Something isn't working enhancement New feature or request labels Apr 18, 2024
@ysbaddaden ysbaddaden self-assigned this Apr 18, 2024
@ysbaddaden
Copy link
Owner Author

ysbaddaden commented Jun 17, 2024

This could be executed by the monitoring thread every once in a while (see #5), instead of starting a fiber in each execution context.

@ysbaddaden
Copy link
Owner Author

Among the nicer heuristics: we could keep the monotonic time when a stack is returned into the pool, and free the stacks that haven't been recycled during the last N seconds.

The balance is in how long does it take the map and unmap a stack vs how long does it take to get the monotonic time.

@ysbaddaden ysbaddaden linked a pull request Jun 20, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant