PS10083 8.4 fix apple build#5943
Closed
jankowsk wants to merge 1 commit into
Closed
Conversation
The static_assert(sizeof(thread_group_t) == 512, ...) in
sql/threadpool_unix.cc has existed since PS 8.0.12 and was hand-tuned
against the Linux/glibc layout of the embedded mysql_mutex_t and PSI
structures. PS-10083 ("Add more statistics for threadpool", merged
2026-03-11 between 9.6.0 and 9.7.0) inserted two LiveStats members into
thread_group_t and adjusted the trailing 'char padding[]' from 328 to
248 to keep the Linux total at exactly 512.
LiveStats itself is platform-neutral (5 PODs, 40 bytes), but
mysql_mutex_t expands by ~128 bytes on macOS / Apple clang + libc++,
so on that platform the struct lands at 640 bytes and breaks the
build:
sql/threadpool_unix.cc:155:1: error: static assertion failed due
to requirement 'sizeof(thread_group_t) == 512'
The false-sharing guarantee comes from alignas(128); what matters is
that the struct occupies a whole number of 128-byte cache lines, not
that it is exactly 512 bytes (640 is also a multiple of 128). Replace
the equality check with 'sizeof % 128 == 0' so Linux/glibc, libc++
on macOS, and any future libstdc++ layout drift all pass while the
no-false-sharing invariant remains enforced.
Contributor
Author
|
We decided to include this in #5942 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The static_assert(sizeof(thread_group_t) == 512, ...) in sql/threadpool_unix.cc has existed since PS 8.0.12 and was hand-tuned against the Linux/glibc layout of the embedded mysql_mutex_t and PSI structures. PS-10083 ("Add more statistics for threadpool", merged 2026-03-11 between 9.6.0 and 9.7.0) inserted two LiveStats members into thread_group_t and adjusted the trailing 'char padding[]' from 328 to 248 to keep the Linux total at exactly 512.
LiveStats itself is platform-neutral (5 PODs, 40 bytes), but mysql_mutex_t expands by ~128 bytes on macOS / Apple clang + libc++, so on that platform the struct lands at 640 bytes and breaks the build:
The false-sharing guarantee comes from alignas(128); what matters is that the struct occupies a whole number of 128-byte cache lines, not that it is exactly 512 bytes (640 is also a multiple of 128). Replace the equality check with 'sizeof % 128 == 0' so Linux/glibc, libc++ on macOS, and any future libstdc++ layout drift all pass while the no-false-sharing invariant remains enforced.