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

Remove overhead from unnecessary MDL_context_owner inheritance

    XMLWordPrintable

Details

    Description

      Metadata locking uses a class MDL_context_owner:

      /**
         An interface to separate the MDL module from the THD, and the rest of the
         server code.
       */
       
      class MDL_context_owner {
      ...
        virtual int  is_killed() = 0;
        virtual THD* get_thd() = 0;
      

      class THD: public THD_count, /* this must be first */
      ...
                 public MDL_context_owner,
      ...
        virtual int is_killed() { return killed; }
        virtual THD* get_thd() { return this; }
      

      It appears MDL_context_owner is only used as a base class of a THD object, in effect MDL_context_owner is a THD, as is also seen by the need to implement virtual functions such as get_thd().

      Such virtual functions create run-time overhead (is_killed() is a frequently called function, for one), and needlessly complicate the code.

      So let's remove this and make it clear in the code that MDL_context_owner is in fact a THD. For example by simply passing in THD instead of MDL_context_owner in the places that need to have a THD, or perhaps upcasting in get_thd(); in any case remove the virtual functions that only have a single implementation across the server code.

      Attachments

        Activity

          People

            knielsen Kristian Nielsen
            knielsen Kristian Nielsen
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Git Integration

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