8000 Reduce HT_MAX_SIZE to account for the max load factor of 0.5 by arnaud-lb · Pull Request #10242 · php/php-src · GitHub
[go: up one dir, main page]

Skip to content

Reduce HT_MAX_SIZE to account for the max load factor of 0.5 #10242

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

Merged
merged 3 commits into from
Jan 13, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Expand comment
  • Loading branch information
arnaud-lb committed Jan 7, 2023
commit 2465dfa1e2af1c49e33d78a8b33fc786d7f2ccb8
9 changes: 8 additions & 1 deletion Zend/zend_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,15 @@ struct _zend_array {
#define HT_MIN_MASK ((uint32_t) -2)
#define HT_MIN_SIZE 8

/* HT_MAX_SIZE is chosen to satisfy the following constraints:
* - HT_SIZE_TO_MASK(HT_MAX_SIZE) != 0
* - HT_SIZE_EX(HT_MAX_SIZE, HT_SIZE_TO_MASK(HT_MAX_SIZE)) does not overflow or
* wrapparound, and is <= the addressable space size
* - HT_MAX_SIZE must be a power of two:
* (nTableSize<HT_MAX_SIZE ? nTableSize+nTableSize : nTableSize) <= HT_MAX_SIZE
*/
#if SIZEOF_SIZE_T == 4
# define HT_MAX_SIZE 0x02000000 /* small enough to avoid overflow checks */
# define HT_MAX_SIZE 0x02000000
Copy link
Member Author

Choose a reason for hiding this comment

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

This is SSIZE_MAX/(sizeof(Bucket)+2*sizeof(uint32_t)) (0x3ffffff) rounded down to the closest power of two

# define HT_HASH_TO_BUCKET_EX(data, idx) \
((Bucket*)((char*)(data) + (idx)))
# define HT_IDX_TO_HASH(idx) \
Expand Down
0