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

Align fiber C stack size #7084

Closed
wants to merge 1 commit into from
Closed

Align fiber C stack size #7084

wants to merge 1 commit into from

Conversation

twose
Copy link
Member

@twose twose commented Jun 1, 2021

Also, align the macro names.
Generally, macro definitions are always at the top of the file, it's easier to edit.

Also align the macro names and generally macro definitions are always at the top of the file.
size = ZEND_FIBER_DEFAULT_C_STACK_SIZE;
} else if (size < ZEND_FIBER_MIN_C_STACK_SIZE) {
size = ZEND_FIBER_MIN_C_STACK_SIZE;
} else if (size > ZEND_FIBER_MAX_C_STACK_SIZE) {
Copy link
Member

Choose a reason for hiding this comment

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

Do we actually need a maximum here? Does it pose any issues if exceeded, or is it arbitrary?

Copy link
Member Author

Choose a reason for hiding this comment

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

I do not think it's a good idea to set a huge C stack size for fibers, it is usually a mistake to set it a huge value.
Professionals can modify ZEND_FIBER_MAX_C_STACK_SIZE to remove the limitation, it is also a kind of configuration.

@@ -25,6 +25,15 @@

BEGIN_EXTERN_C()

#define ZEND_FIBER_C_STACK_ALIGNMENT (4 * 1024)
#define ZEND_FIBER_DEFAULT_C_STACK_SIZE (ZEND_FIBER_C_STACK_ALIGNMENT * (sizeof(void *) * 64))
#define ZEND_FIBER_MIN_C_STACK_SIZE (128 * 1024)
Copy link
Member

Choose a reason for hiding this comment

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

Why this as a minimum stack size. ZEND_FIBER_C_STACK_ALIGNMENT * (ZEND_FIBER_GUARD_PAGES + 1) should work, so why require more if the user wishes to set it to the minimum?

Copy link
Member Author

Choose a reason for hiding this comment

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

After we rely on the virtual memory mechanism, too small a C stack size does not seem to make any sense, it will only increase the risk of the crash.
Professionals can still remove the limitation by changing the macro definition.

@twose twose closed this Jun 4, 2021
@twose twose deleted the fiber-align branch June 4, 2021 04:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants