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

Optimize InnoDB code around mutexes assuming InnoDB locks are uncontended

    XMLWordPrintable

    Details

      Description

      The InnoDB engine locks have low contention during OLTP_PS/RO sysbench tests. Assuming this we used compiler specific attributes to annotate code near mutexes making code path acquiring lock easier. Specifically, branches which lead to ut_delay() function were marked `unlikely` and functions which call ut_delay() were marked `cold`. We got persistent +2% improvement in sysbench OLTP_PS 128 thread, meanwhile sysbench OTLP_RO/RW results almost didn't change.

      Our environment: Kunpeng 920 (64 cores), Ubuntu 20.04, kernel 5.6.0 with 64K pages, gcc-9.3.0.

      Look at the TTASEventMutex implementation, for instance. Here, we can mark while(!try_lock()) as unlikely:

      void enter(
      		uint32_t	max_spins,
      		uint32_t	max_delay,
      		const char*	filename,
      		uint32_t	line)
      		UNIV_NOTHROW
      	{
      		uint32_t	n_spins = 0;
      		uint32_t	n_waits = 0;
      		const uint32_t	step = max_spins;
       
      		while (UNIV_UNLIKELY(!try_lock())) {
                      ...
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              marko Marko Mäkelä
              Reporter:
              dmitriy.philimonov Dmitriy Philimonov
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Dates

                Created:
                Updated: