mariadb/storage
Marko Mäkelä 699d38d951 MDEV-34296 extern thread_local is a CPU waste
In commit 99bd22605938c42d876194f2ec75b32e658f00f5 (MDEV-31558)
we wrongly thought that there would be minimal overhead for accessing
a thread-local variable mariadb_stats.

It turns out that in C++11, each access to an extern thread_local
variable requires conditionally invoking an initialization function.
In fact, the initializer expression of mariadb_stats is dynamic, and
those calls were actually unavoidable.

In C++20, one could declare constinit thread_local variables, but
the address of a thread_local variable (&mariadb_dummy_stats) is not
a compile-time constant. We did not want to declare mariadb_dummy_stats
without thread_local, because then the dummy accesses could lead to
cache line contention between threads.

mariadb_stats: Declare as __thread or __declspec(thread) so that
there will be no dynamic initialization, but zero-initialization.

mariadb_dummy_stats: Remove. It is a lesser evil to let
the environment perform zero-initialization and check if
!mariadb_stats.

Reviewed by: Sergei Petrunia
2024-06-06 14:38:42 +03:00
..
archive Merge branch '10.5' into 10.6 2024-05-08 20:06:00 +02:00
blackhole Merge 10.4 into 10.5 2023-02-10 12:02:11 +02:00
columnstore columnstore 6.4.8-2 2024-05-09 00:04:20 +02:00
connect Merge branch '10.5' into 10.6 2024-05-08 20:06:00 +02:00
csv Backporting bugs fixes fixed by MDEV-31340 from 11.5 2024-05-21 14:58:01 +04:00
example Merge branch '10.4' into 10.5 2023-12-02 01:02:50 +01:00
federated Merge 10.5 into 10.6 2023-02-10 13:03:01 +02:00
federatedx Merge branch '10.5' into 10.6 2024-01-31 18:04:03 +01:00
heap Merge 10.5 into 10.6 2024-05-30 14:27:07 +03:00
innobase MDEV-34296 extern thread_local is a CPU waste 2024-06-06 14:38:42 +03:00
maria Merge branch '10.5' into 10.6 2024-05-08 20:06:00 +02:00
mroonga Merge branch '10.5' into 10.6 2024-05-08 20:06:00 +02:00
myisam Merge branch '10.5' into 10.6 2024-05-08 20:06:00 +02:00
myisammrg Fixed some mtr tests that failed on windows 2024-01-23 13:03:12 +02:00
oqgraph Merge 10.5 into 10.6 2023-09-11 14:46:39 +03:00
perfschema Merge 10.5 into 10.6 2024-05-30 14:27:07 +03:00
rocksdb Merge branch '10.5' into 10.6 2024-05-08 20:06:00 +02:00
sequence Merge 10.4 into 10.5 2023-02-10 12:02:11 +02:00
sphinx Merge branch '10.5' into 10.6 2024-01-11 12:59:22 +11:00
spider Merge branch '10.5' into 10.6 2024-05-31 09:10:17 +10:00
test_sql_discovery Merge 10.5 into 10.6 2022-09-20 16:53:20 +03:00