-
Notifications
You must be signed in to change notification settings - Fork 8.1k
perf: move EG() and CG() in ZTS builds into __thread storage #23227
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
Open
henderkes
wants to merge
12
commits into
php:master
Choose a base branch
from
henderkes:perf/1-tls-eg-cg
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
b2dc217
perf: embed executor and compiler globals in the __thread TLS cache s…
henderkes 2a7884d
fix typo
henderkes 2e248cb
leave the option of initial-exec tls model even for apache2handler if…
henderkes 4aef0ba
remove ts_allocate_fast_id_at again (unused, now that the four global…
henderkes 4633dc0
guard ts_apply_for_id and ts_free_id for own threads globals too
henderkes d67443a
reword comment
henderkes c509919
simplify linux aarch64 jit generator
henderkes bd1730d
stupid typo
henderkes fdc77a4
clarification
henderkes 06f5bba
abort, rather than assert
henderkes 209979d
largely revert jit, just offsetof self* in the tsrm struct
henderkes 5d9e202
LE guard for external embedders
henderkes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -95,11 +95,6 @@ TSRM_API ts_rsrc_id ts_allocate_id(ts_rsrc_id *rsrc_id, size_t size, ts_allocate | |
| TSRM_API void tsrm_reserve(size_t size); | ||
| TSRM_API ts_rsrc_id ts_allocate_fast_id(ts_rsrc_id *rsrc_id, size_t *offset, size_t size, ts_allocate_ctor ctor, ts_allocate_dtor dtor); | ||
|
|
||
| /* Fast resources at caller-chosen, compile-time-constant offsets. The fixed | ||
| * front region must be reserved after tsrm_reserve() and before any fast id. */ | ||
| TSRM_API void tsrm_reserve_fast_front(size_t size); | ||
| TSRM_API ts_rsrc_id ts_allocate_fast_id_at(ts_rsrc_id *rsrc_id, size_t *offset, ptrdiff_t fixed_offset, size_t size, ts_allocate_ctor ctor, ts_allocate_dtor dtor); | ||
|
|
||
| /* Resource whose per-thread storage is a native __thread block. | ||
| * Must be called at startup before any other thread exists. */ | ||
| TSRM_API ts_rsrc_id ts_allocate_tls_id(ts_rsrc_id *rsrc_id, void *(*tls_addr)(void), size_t size, ts_allocate_ctor ctor, ts_allocate_dtor dtor); | ||
|
|
@@ -166,9 +161,14 @@ TSRM_API bool tsrm_is_managed_thread(void); | |
| || defined(__MUSL__) || defined(__HAIKU__) || defined(_AIX) | ||
| # define TSRM_TLS_MODEL_ATTR | ||
| # define TSRM_TLS_MODEL_DEFAULT | ||
| #elif defined(__PIC__) && !defined(__PIE__) | ||
| # define TSRM_TLS_MODEL_ATTR __attribute__((tls_model("initial-exec"))) | ||
| # define TSRM_TLS_MODEL_INITIAL_EXEC | ||
| #elif (defined(__PIC__) && !defined(__PIE__)) || !defined(ZEND_ENABLE_STATIC_TSRMLS_CACHE) | ||
| # if defined(TSRM_TLS_MODEL_USE_GLOBAL_DYNAMIC) | ||
| # define TSRM_TLS_MODEL_ATTR __attribute__((tls_model("global-dynamic"))) | ||
| # define TSRM_TLS_MODEL_GLOBAL_DYNAMIC | ||
| # else | ||
| # define TSRM_TLS_MODEL_ATTR __attribute__((tls_model("initial-exec"))) | ||
| # define TSRM_TLS_MODEL_INITIAL_EXEC | ||
| # endif | ||
| #else | ||
| # define TSRM_TLS_MODEL_ATTR __attribute__((tls_model("local-exec"))) | ||
| # define TSRM_TLS_MODEL_LOCAL_EXEC | ||
|
|
@@ -186,17 +186,27 @@ TSRM_API bool tsrm_is_managed_thread(void); | |
| #define TSRMG_BULK_STATIC(id, type) ((type) (*((void ***) TSRMLS_CACHE))[TSRM_UNSHUFFLE_RSRC_ID(id)]) | ||
| #define TSRMG_FAST_STATIC(offset, type, element) (TSRMG_FAST_BULK_STATIC(offset, type)->element) | ||
| #define TSRMG_FAST_BULK_STATIC(offset, type) ((type) (((char*) TSRMLS_CACHE)+(offset))) | ||
| struct _zend_tsrm_ls_cache; | ||
| #if defined(ZEND_WIN32) && !defined(LIBZEND_EXPORTS) | ||
| /* Windows can't dllexport __declspec(thread) symbols, so outside Zend each module | ||
| * keeps a per-module `void *` pointer and reaches EG/CG via the resource-id indirection. */ | ||
| # define ZEND_TSRMLS_CACHE_T void * | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The symbol is referenced as just a void* on windows |
||
| # define TSRMLS_MAIN_CACHE_DEFINE() TSRM_TLS void *_tsrm_ls_cache TSRM_TLS_MODEL_ATTR = NULL; | ||
| # define TSRMLS_CACHE_DEFINE() TSRM_TLS void *_tsrm_ls_cache = NULL; | ||
| #else | ||
| # define ZEND_TSRMLS_CACHE_T struct _zend_tsrm_ls_cache | ||
| # define TSRMLS_MAIN_CACHE_DEFINE() | ||
| # define TSRMLS_CACHE_DEFINE() | ||
| #endif | ||
| #ifdef __cplusplus | ||
| #define TSRMLS_MAIN_CACHE_EXTERN() extern "C" { extern TSRM_TLS void *TSRMLS_CACHE TSRM_TLS_MODEL_ATTR; } | ||
| #define TSRMLS_CACHE_EXTERN() extern "C" { extern TSRM_TLS void *TSRMLS_CACHE; } | ||
| #define TSRMLS_MAIN_CACHE_EXTERN() extern "C" { extern TSRM_TLS ZEND_TSRMLS_CACHE_T _tsrm_ls_cache TSRM_TLS_MODEL_ATTR; } | ||
| #define TSRMLS_CACHE_EXTERN() extern "C" { extern TSRM_TLS ZEND_TSRMLS_CACHE_T _tsrm_ls_cache; } | ||
| #else | ||
| #define TSRMLS_MAIN_CACHE_EXTERN() extern TSRM_TLS void *TSRMLS_CACHE TSRM_TLS_MODEL_ATTR; | ||
| #define TSRMLS_CACHE_EXTERN() extern TSRM_TLS void *TSRMLS_CACHE; | ||
| #define TSRMLS_MAIN_CACHE_EXTERN() extern TSRM_TLS ZEND_TSRMLS_CACHE_T _tsrm_ls_cache TSRM_TLS_MODEL_ATTR; | ||
| #define TSRMLS_CACHE_EXTERN() extern TSRM_TLS ZEND_TSRMLS_CACHE_T _tsrm_ls_cache; | ||
| #endif | ||
| #define TSRMLS_MAIN_CACHE_DEFINE() TSRM_TLS void *TSRMLS_CACHE TSRM_TLS_MODEL_ATTR = NULL; | ||
| #define TSRMLS_CACHE_DEFINE() TSRM_TLS void *TSRMLS_CACHE = NULL; | ||
| #define TSRMLS_CACHE_UPDATE() TSRMLS_CACHE = tsrm_get_ls_cache() | ||
| #define TSRMLS_CACHE _tsrm_ls_cache | ||
| #define TSRMLS_CACHE (*(void **) &_tsrm_ls_cache) | ||
|
|
||
| #ifdef __cplusplus | ||
| } | ||
|
|
||
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
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.
deref here too, so also for this the cache* has to stay the first member