AK: Allow alignment to cache line size with CACHE_ALIGNED
This is particularly important to avoid false sharing, which thrashes performance when two process-shared atomics are on the same cache line.
This commit is contained in:
parent
d463f6e00a
commit
65b338ad04
Notes:
sideshowbarker
2024-07-17 11:37:27 +09:00
Author: https://github.com/kleinesfilmroellchen Commit: https://github.com/SerenityOS/serenity/commit/65b338ad04 Pull-request: https://github.com/SerenityOS/serenity/pull/12102 Issue: https://github.com/SerenityOS/serenity/issues/11882 Reviewed-by: https://github.com/ADKaster Reviewed-by: https://github.com/Hendiadyoin1 Reviewed-by: https://github.com/bgianfo Reviewed-by: https://github.com/linusg
1 changed files with 13 additions and 0 deletions
|
@ -110,3 +110,16 @@ extern "C" {
|
|||
# define CLOCK_MONOTONIC_COARSE CLOCK_MONOTONIC
|
||||
# define CLOCK_REALTIME_COARSE CLOCK_REALTIME
|
||||
#endif
|
||||
|
||||
#ifndef SYSTEM_CACHE_ALIGNMENT_SIZE
|
||||
# if ARCH(AARCH64) || ARCH(x86_64)
|
||||
# define SYSTEM_CACHE_ALIGNMENT_SIZE 64
|
||||
# else
|
||||
# define SYSTEM_CACHE_ALIGNMENT_SIZE 128
|
||||
# endif
|
||||
#endif /* SYSTEM_CACHE_ALIGNMENT_SIZE */
|
||||
|
||||
#ifdef CACHE_ALIGNED
|
||||
# undef CACHE_ALIGNED
|
||||
#endif
|
||||
#define CACHE_ALIGNED alignas(SYSTEM_CACHE_ALIGNMENT_SIZE)
|
||||
|
|
Loading…
Add table
Reference in a new issue