Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-33748

get rid of pthread_key_(get_/set_)specific API, replace with C-style thread_local

Details

    Description

      Every major compiler has some notion of thread local storage

      In C++11, there is thread_local , as per standard.

      In C, in the newer standards, it is _Thread_local (C11) , or thread_local (C23) , and before that all relevant compiler have had notion of "thread local variable" for many years , i.e __thread in GCC or __declspec(thread) in MSVC,

      Apart from better performance when accessing thread local variables, we'll get rid of things that depend on
      initialization/cleanup of pthread_key_t variables.

      "/tmp/workspace/Source-Build-Test/src/storage/perfschema/pfs.cc", line=line@entry=1379, function=function@entry=0xaaaad18df558 "void my_thread_set_THR_PFS(PFS_thread*)") at assert.c:92
      #7  0x0000ffffa19e9684 in __GI___assert_fail (assertion=0xaaaad18df508 "THR_PFS_initialized", file=0xaaaad18df4c8 "/tmp/workspace/Source-Build-Test/src/storage/perfschema/pfs.cc", line=1379, function=0xaaaad18df558 "void my_thread_set_THR_PFS(PFS_thread*)") at assert.c:101
      

      Attachments

        Issue Links

          Activity

            wlad Vladislav Vaintroub created issue -
            wlad Vladislav Vaintroub made changes -
            Field Original Value New Value
            wlad Vladislav Vaintroub made changes -
            Summary get rid of pthread_key_xxx API, replace with C-style thread_local get rid of pthread_key_(get_/set_)specific API, replace with C-style thread_local
            wlad Vladislav Vaintroub made changes -
            Description Every major compiler has some notion of thread local storage

            In C++11, there is thread_local , as per standard.

            In C, in the newer standards, it is _Thread_local (C11) , or thread_local (C23) , and before that all relevant compiler have had notion of "thread local variable" for many years , i.e __thread in GCC or __declspec(thread) in MSVC,

            Apart from better performance when accessing thread local variables, we'll get rid of things like below

            {noformat}
            "/tmp/workspace/Source-Build-Test/src/storage/perfschema/pfs.cc", line=line@entry=1379, function=function@entry=0xaaaad18df558 "void my_thread_set_THR_PFS(PFS_thread*)") at assert.c:92
            #7 0x0000ffffa19e9684 in __GI___assert_fail (assertion=0xaaaad18df508 "THR_PFS_initialized", file=0xaaaad18df4c8 "/tmp/workspace/Source-Build-Test/src/storage/perfschema/pfs.cc", line=1379, function=0xaaaad18df558 "void my_thread_set_THR_PFS(PFS_thread*)") at assert.c:101
            {noformat}
            Every major compiler has some notion of thread local storage

            In C++11, there is thread_local , as per standard.

            In C, in the newer standards, it is _Thread_local (C11) , or thread_local (C23) , and before that all relevant compiler have had notion of "thread local variable" for many years , i.e __thread in GCC or __declspec(thread) in MSVC,

            Apart from better performance when accessing thread local variables, we'll get rid of things that depend on
            initialization/cleanup of pthread_key_t variables.

            {noformat}
            "/tmp/workspace/Source-Build-Test/src/storage/perfschema/pfs.cc", line=line@entry=1379, function=function@entry=0xaaaad18df558 "void my_thread_set_THR_PFS(PFS_thread*)") at assert.c:92
            #7 0x0000ffffa19e9684 in __GI___assert_fail (assertion=0xaaaad18df508 "THR_PFS_initialized", file=0xaaaad18df4c8 "/tmp/workspace/Source-Build-Test/src/storage/perfschema/pfs.cc", line=1379, function=0xaaaad18df558 "void my_thread_set_THR_PFS(PFS_thread*)") at assert.c:101
            {noformat}
            wlad Vladislav Vaintroub made changes -
            Status Open [ 1 ] In Progress [ 3 ]
            wlad Vladislav Vaintroub made changes -
            Assignee Vladislav Vaintroub [ wlad ] Nikita Malyavin [ nikitamalyavin ]
            Status In Progress [ 3 ] In Review [ 10002 ]
            nikitamalyavin Nikita Malyavin added a comment - - edited

            The last solution is lovely.

            Especially given that LTO is now fixed per MDEV-25633, it's efficient enough.
            As discussed, there's a small improvement window for shared objects, to eliminate an extra function call, but there's no shared object access to mysys_var at all.

            Ok to push, to mention.

            Thank you wlad!

            nikitamalyavin Nikita Malyavin added a comment - - edited The last solution is lovely. Especially given that LTO is now fixed per MDEV-25633 , it's efficient enough. As discussed, there's a small improvement window for shared objects, to eliminate an extra function call, but there's no shared object access to mysys_var at all. Ok to push, to mention. Thank you wlad !
            nikitamalyavin Nikita Malyavin made changes -
            Assignee Nikita Malyavin [ nikitamalyavin ] Vladislav Vaintroub [ wlad ]
            Status In Review [ 10002 ] Stalled [ 10000 ]
            ralf.gebhardt Ralf Gebhardt made changes -
            Priority Major [ 3 ] Critical [ 2 ]
            wlad Vladislav Vaintroub made changes -
            issue.field.resolutiondate 2024-06-21 12:35:58.0 2024-06-21 12:35:58.248
            wlad Vladislav Vaintroub made changes -
            Component/s Server [ 13907 ]
            Fix Version/s 11.6.1 [ 29847 ]
            Fix Version/s 11.6 [ 29515 ]
            Resolution Fixed [ 1 ]
            Status Stalled [ 10000 ] Closed [ 6 ]

            People

              wlad Vladislav Vaintroub
              wlad Vladislav Vaintroub
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.