-
Notifications
You must be signed in to change notification settings - Fork 7.8k
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
Compress interned string table offsets and increase maximum supported buffer size #13676
Conversation
… buffer size The interned string buffer is organized as a header + a hash table + a zend_string arena. Hash slots point to the arena, but are represented as 32bit offsets from the buffer, which limits the maximum buffer size to about 4GiB. However zend_strings are 8-byte aligned in the buffer, so we can compress the 3 lower bits. This allows to increase the maximum supported interned string buffer size from 4095 MiB to 16367 MiB.
ZEND_MM_ALIGNED_SIZE_EX(_ZSTR_HEADER_SIZE + ZSTR_LEN(s) + 5, 8) | ||
ZEND_MM_ALIGNED_SIZE_EX(_ZSTR_STRUCT_SIZE(ZSTR_LEN(s)) + sizeof(zend_string_table_pos_t), ZEND_STRING_TABLE_POS_ALIGNMENT) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
5
here accounted for the null byte after ZSTR_LEN(s)
+ a slot for the collision chain.
The patch looks good.
|
/* nTableMask must not overflow (uint32_t) */ \ | ||
UINT32_MAX / (32 * 1024 * sizeof(zend_string_table_pos_t)) \ | ||
), \ | ||
/* SHM allocation must not overlow (size_t) */ \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit:
/* SHM allocation must not overlow (size_t) */ \ | |
/* SHM allocation must not overflow (size_t) */ \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
@dstogov this is related to #13598. I'm assuming a shared hosting use-case Symfony demo benchmarks:
|
Yea, like you wrote, this will solve a lot of "problems" (use cases) on shared webhostings. Thank you for this PR. Btw, I am little surprised no one else reported this issue... Maybe nobody cares :)) But our company openservis.cz cares, so we are trying to make best performance for our customers, so, we cares :) |
The interned string buffer is organized as a header + a hash table + a zend_string arena. Hash slots point to the arena, but are represented as 32bit offsets from the buffer, which limits the maximum buffer size to about 4GiB. However zend_strings are 8-byte aligned in the buffer, so we can compress the 3 lower bits. This allows to increase the maximum supported interned string buffer size from 4095 MiB to 32767 MiB.