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

Shrink stack size for unused threads #88

Open
btrask opened this issue Aug 23, 2015 · 0 comments
Open

Shrink stack size for unused threads #88

btrask opened this issue Aug 23, 2015 · 0 comments

Comments

@btrask
Copy link
Owner

btrask commented Aug 23, 2015

We use libco for fibers which allocate their own stacks. That means we basically don't use the default stack for the main thread and the worker threads we spawn. I don't think there's a way to shrink the main thread once the process is already running, but we could cap the worker threads before we spawn them.

See also pthread_attr_setstacksize, PTHREAD_STACK_MIN

Not sure about portability. Could be POSIX-only for now.

Edit: This would save a little bit of address space but I guess the main advantage would be fragmentation? If the default stack space is 8MB and we spawn 16 worker threads, that's almost 128MB we're wasting (but the kernel VM means it's not as bad as it sounds).

Edit: It's a bigger deal on 32-bit.

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

No branches or pull requests

1 participant