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

LP:941889 - JOIN constructors takes a long time in 5.3

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:

      Description

      I run sysbench on MariaDB on Windows with Visual Studio sampling profiler , comparing 5.2 and 5.3 performance.
      sysbench version is 0.5 and for the test I created select1.lua, which does nothing else but running prepared "SELECT 1".

      Performance reports show a big difference inside JOIN constructor, and for this specific test JOIN::JOIN is the most expensive function with 24.23% exclusive samples.

      Here is he list of functions that show up as more expensive in 5.3 compared to 5.2

      Comparison Column Delta Baseline Value Comparison Value
      JOIN::JOIN 23,15 1,08 24,23
      RtlpAllocateHeap 3,24 0,00 3,24
      RtlpInsertFreeBlock 1,93 0,00 1,93
      RtlpFreeHeap 1,42 0,00 1,42

      Looking at what has changed from 5.2 to 5.3, JOIN structure grew from around 5K to around 32K. Besides, it contains 2 large arrays of POSITION structures, and POSITION has a non-trivial constructor, since it includes semi-join strategy classes for which virtual function tables must be setup (confirmed by switching to disassembly and single-stepping through JOIN::JOIN)

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            wlad Vladislav Vaintroub added a comment -

            Re: JOIN constructors takes a long time in 5.3
            Attached in a simple patch that de-virtualizes semijoin strategy picker classes.

            It fixes the problem (tested on Windows)

            • SELECT 1 test (10 users)

            5.3, without fix
            read/write requests: 11739503 (39131.57 per sec.)
            read/write requests: 11787997 (39293.23 per sec.)
            read/write requests: 11776222 (39253.97 per sec.)

            5.3, with fix
            read/write requests: 12887151 (42957.08 per sec.)
            read/write requests: 12876115 (42920.29 per sec.)
            read/write requests: 12925002 (43083.25 per sec.)

            5.2
            read/write requests: 13186290 (43954.19 per sec.)
            read/write requests: 13099010 (43663.26 per sec.)
            read/write requests: 13115124 (43716.98 per sec.)

            Summary on SELECT 1:

            • The fix speeds up 5.3 on this test by 9.7%
            • 5.3 is stil a bit slower than 5.2 (approx 1%)

            Another test : OLTP_RO (64 users, sysbench 0.4)

            5.3:
            read/write requests: 4869802 (27051.41 per sec.)
            read/write requests: 4795000 (26635.60 per sec.)
            read/write requests: 4948034 (27485.88 per sec.)

            5.3-fix
            read/write requests: 5354006 (29741.23 per sec.)
            read/write requests: 5327574 (29593.89 per sec.)
            read/write requests: 5477906 (30429.07 per sec.)

            Summary on OLTP-RO:
            Fix makes 5.3 ~ 10.6% faster

            Show
            wlad Vladislav Vaintroub added a comment - Re: JOIN constructors takes a long time in 5.3 Attached in a simple patch that de-virtualizes semijoin strategy picker classes. It fixes the problem (tested on Windows) SELECT 1 test (10 users) 5.3, without fix read/write requests: 11739503 (39131.57 per sec.) read/write requests: 11787997 (39293.23 per sec.) read/write requests: 11776222 (39253.97 per sec.) 5.3, with fix read/write requests: 12887151 (42957.08 per sec.) read/write requests: 12876115 (42920.29 per sec.) read/write requests: 12925002 (43083.25 per sec.) 5.2 read/write requests: 13186290 (43954.19 per sec.) read/write requests: 13099010 (43663.26 per sec.) read/write requests: 13115124 (43716.98 per sec.) Summary on SELECT 1: The fix speeds up 5.3 on this test by 9.7% 5.3 is stil a bit slower than 5.2 (approx 1%) Another test : OLTP_RO (64 users, sysbench 0.4) 5.3: read/write requests: 4869802 (27051.41 per sec.) read/write requests: 4795000 (26635.60 per sec.) read/write requests: 4948034 (27485.88 per sec.) 5.3-fix read/write requests: 5354006 (29741.23 per sec.) read/write requests: 5327574 (29593.89 per sec.) read/write requests: 5477906 (30429.07 per sec.) Summary on OLTP-RO: Fix makes 5.3 ~ 10.6% faster
            Hide
            wlad Vladislav Vaintroub added a comment -

            Fix to previously posted patch, makes compile with gcc's -fno-implicit-templates
            LPexportBug941889_941889.diff

            Show
            wlad Vladislav Vaintroub added a comment - Fix to previously posted patch, makes compile with gcc's -fno-implicit-templates LPexportBug941889_941889.diff
            Hide
            wlad Vladislav Vaintroub added a comment -

            Re: JOIN constructors takes a long time in 5.3

            Show
            wlad Vladislav Vaintroub added a comment - Re: JOIN constructors takes a long time in 5.3
            Hide
            monty Michael Widenius added a comment -

            Re: JOIN constructors takes a long time in 5.3
            Now we allocate just as much memory that is needed. This shows a notable speedup compared even to MariaDB 5.2!

            Show
            monty Michael Widenius added a comment - Re: JOIN constructors takes a long time in 5.3 Now we allocate just as much memory that is needed. This shows a notable speedup compared even to MariaDB 5.2!
            Hide
            ratzpo Rasmus Johansson added a comment -

            Launchpad bug id: 941889

            Show
            ratzpo Rasmus Johansson added a comment - Launchpad bug id: 941889

              People

              • Assignee:
                monty Michael Widenius
                Reporter:
                wlad Vladislav Vaintroub
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: