-
-
Notifications
You must be signed in to change notification settings - Fork 698
provide an option to set the default stack size on linux #1291
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
Conversation
Hello @abdollar, This feels ugly! This kind of thing should not be set by libraries. But I agree that (like that horrible stdio hack for Windows) it makes pragmatic sense. How about checking the current stacksize and making sure we don't lower it? There would then be less danger of fighting with some other library over stacksize. The env var could perhaps be renamed I would use I agree, 2m seems a sensible minimum. |
b0e5cbf
to
0da40ef
Compare
@jcupitt - updated changes and description per your suggestions of VIPS_MIN_STACK_SIZE. I added a warning if the current stack size is larger indicating we are not going to change it and included the current settings. So - I was debating adding this and going back and forth on this change. It seems to make sense due to the init section and thread pool being managed here and it feels right especially for those of us with containers and environment variables. Thanks. |
Does the stack size need to be aligned to the page size? https://linux.die.net/man/3/pthread_attr_setstacksize |
I found this issue discussing the 80kb limit and how to step around it. There are interesting links to the solutions other projects have cooked up. https://github.com/voidlinux/void-packages/issues/4147 Our case is slightly different from the large stack frames allocations they discuss. Poppler walks the document structure recursively, so the low limit simply makes some common user input impossible to handle. @lovell I think you need to be page-aligned for setstack, but the stack size does not need to be. It looks like not all pthread implementations have |
0da40ef
to
25bfad1
Compare
@jcupitt - I have updated configure and added a library check to include HAVE_PTHREAD_DEFAULT_NP using AC_CHECK_LIB([pthread]. I removed the linux check, but could add it back, though this seems to make more sense for any thing with pthreads and pthread_setattr_default_np. |
Nice! Looks good to me, anyone have any other comments? |
OK, let's merge! Thank you for working on this, @abdollar, it's a nice improvement. |
- need to define _GNU_SOURCE for glibc to get pthread_setattr_default_np() - don't warn if we already have enough stack - reformat to libvips standard - add note to docs see: #1291
I added |
provide an option to set the default stack size on linux
e.g it can be used like so, if you pass a string it defaults to 2MB otherwise the value passed.
If you try to set it too low you see the following warning