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

Item::cmp_type() takes 0.15% in OLTP RO

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 10.1
    • Fix Version/s: 10.1
    • Component/s: None
    • Labels:
      None

      Description

      Data comes from Sandy Bridge system running sysbench OLTP RO in 1 thread against 1 table.

      Call graphs:

      -   0.15%  mysqld  mysqld
         - Item::cmp_type() const
            + 37.20% Item_func::fix_fields(THD*, Item**)
            + 13.65% Item_func::setup_args_and_comparator(THD*, Arg_comparator*)
            + 10.08% Item_equal::add_const(Item*, Item*)
            + 5.16% Item_equal::fix_fields(THD*, Item**)
            + 4.68% build_equal_items_for_cond(THD*, Item*, COND_EQUAL*, bool)
            + 4.36% update_ref_and_keys(THD*, st_dynamic_array*, st_join_table*, unsigned int, Item*, unsigned long long, st_select_lex*, st_sargable_param**) [clone .isra.253]
            + 4.14% get_mm_parts(RANGE_OPT_PARAM*, Item*, Field*, Item_func::Functype, Item*, Item_result) [clone .isra.162] [clone .part.163]
            + 3.54% Item_func_between::fix_length_and_dec()
            + 2.94% check_simple_equality(Item*, Item*, Item*, COND_EQUAL*)
            + 2.69% Item::cache_const_expr_transformer(unsigned char*)
            + 2.13% Item_bool_func2::set_cmp_func()
            + 1.94% Arg_comparator::set_cmp_func(Item_result_field*, Item**, Item**, bool)
            + 1.63% Field::can_optimize_keypart_ref(Item_func const*, Item const*) const
            + 1.27% Item::charset_for_protocol() const
            + 1.11% Item_equal::fix_length_and_dec()
            + 0.95% Item::init_make_field(Send_field*, enum_field_types)
            + 0.80% Protocol::send_result_set_metadata(List<Item>*, unsigned int)
            + 0.79% Item_equal::Item_equal(Item*, Item*, bool)
            + 0.63% get_mm_leaf(RANGE_OPT_PARAM*, Item*, Field*, st_key_part*, Item_func::Functype, Item*)
      

      This is virtual method which can't be inlined. Most time spent for function call convention. Check if we can revoke it's virtual status.

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            bar Alexander Barkov added a comment - - edited

            In this script:

            DROP TABLE IF EXISTS t1;
            CREATE TABLE t1 (
              id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
               k INTEGER UNSIGNED DEFAULT '0' NOT NULL,
               c CHAR(120) DEFAULT '' NOT NULL,
               pad CHAR(60) DEFAULT '' NOT NULL,
               PRIMARY KEY (id)
            ) ENGINE=MyISAM;
            INSERT INTO t1 (k, c, pad) VALUES (10, 'a', 'xxx');
            INSERT INTO t1 (k, c, pad) VALUES (11, 'a', 'xxx');
            INSERT INTO t1 (k, c, pad) VALUES (12, 'a', 'xxx');
            INSERT INTO t1 (k, c, pad) VALUES (13, 'a', 'xxx');
            INSERT INTO t1 (k, c, pad) VALUES (14, 'a', 'xxx');
            INSERT INTO t1 (k, c, pad) VALUES (15, 'a', 'xxx');
            INSERT INTO t1 (k, c, pad) VALUES (16, 'a', 'xxx');
            SELECT * FROM t1 WHERE id=13;
            

            the last SELECT query generates the following Item::cmp_type() calls (7 calls total):

            #1  0x0000555555c788a8 in Item_func::setup_args_and_comparator (
            #2  0x0000555555c78a9b in Item_bool_func2::fix_length_and_dec (
            #3  0x0000555555ca5e38 in Item_func::fix_fields (this=0x7fff500014a8, 
            ...
            #1  0x0000555555a911dd in Arg_comparator::set_cmp_func (this=0x7fff50001570, 
            #2  0x0000555555c78a23 in Item_func::setup_args_and_comparator (
            #3  0x0000555555c78a9b in Item_bool_func2::fix_length_and_dec (
            #4  0x0000555555ca5e38 in Item_func::fix_fields (this=0x7fff500014a8, 
            ...
            #1  0x0000555555a911fc in Arg_comparator::set_cmp_func (this=0x7fff50001570, 
            #2  0x0000555555c78a23 in Item_func::setup_args_and_comparator (
            #3  0x0000555555c78a9b in Item_bool_func2::fix_length_and_dec (
            #4  0x0000555555ca5e38 in Item_func::fix_fields (this=0x7fff500014a8, 
            ...
            #1  0x0000555555a6ef54 in check_simple_equality (thd=0x55555a932650, 
            #2  0x0000555555a6f495 in Item_func_eq::check_equality (this=0x7fff500014a8, 
            #3  0x0000555555a6fa77 in Item_func_eq::build_equal_items (
            #4  0x0000555555a700e3 in build_equal_items (join=0x7fff50001708, 
            #5  0x0000555555a737af in optimize_cond (join=0x7fff50001708, 
            ...
            #1  0x0000555555c89292 in Item_equal::Item_equal (this=0x7fff50002228, 
            #2  0x0000555555a6f18e in check_simple_equality (thd=0x55555a932650, 
            #3  0x0000555555a6f495 in Item_func_eq::check_equality (this=0x7fff500014a8, 
            #4  0x0000555555a6fa77 in Item_func_eq::build_equal_items (
            #5  0x0000555555a700e3 in build_equal_items (join=0x7fff50001708, 
            #6  0x0000555555a737af in optimize_cond (join=0x7fff50001708, 
            ...
            #1  0x0000555555c8a114 in Item_equal::fix_length_and_dec (this=0x7fff50002228)
            #2  0x0000555555c89d79 in Item_equal::fix_fields (this=0x7fff50002228, 
            #3  0x0000555555a6fb38 in Item_func_eq::build_equal_items (
            #4  0x0000555555a700e3 in build_equal_items (join=0x7fff50001708, 
            #5  0x0000555555a737af in optimize_cond (join=0x7fff50001708, 
            ...
            #1  0x0000555555c15e98 in Field::can_optimize_keypart_ref (
            #2  0x0000555555a5c649 in add_key_part (keyuse_array=0x7fff50001a10, 
            #3  0x0000555555a5d6bb in update_ref_and_keys (thd=0x55555a932650, 
            #4  0x0000555555a585e6 in make_join_statistics (join=0x7fff50001708, 
            #5  0x0000555555a505fc in JOIN::optimize_inner (this=0x7fff50001708)
            #6  0x0000555555a4f590 in JOIN::optimize (this=0x7fff50001708)
            

            5 out of 7 calls are done by Item_field
            2 out of 7 calls are done by Item_int

            Show
            bar Alexander Barkov added a comment - - edited In this script: DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, k INTEGER UNSIGNED DEFAULT '0' NOT NULL, c CHAR(120) DEFAULT '' NOT NULL, pad CHAR(60) DEFAULT '' NOT NULL, PRIMARY KEY (id) ) ENGINE=MyISAM; INSERT INTO t1 (k, c, pad) VALUES (10, 'a', 'xxx'); INSERT INTO t1 (k, c, pad) VALUES (11, 'a', 'xxx'); INSERT INTO t1 (k, c, pad) VALUES (12, 'a', 'xxx'); INSERT INTO t1 (k, c, pad) VALUES (13, 'a', 'xxx'); INSERT INTO t1 (k, c, pad) VALUES (14, 'a', 'xxx'); INSERT INTO t1 (k, c, pad) VALUES (15, 'a', 'xxx'); INSERT INTO t1 (k, c, pad) VALUES (16, 'a', 'xxx'); SELECT * FROM t1 WHERE id=13; the last SELECT query generates the following Item::cmp_type() calls (7 calls total): #1 0x0000555555c788a8 in Item_func::setup_args_and_comparator ( #2 0x0000555555c78a9b in Item_bool_func2::fix_length_and_dec ( #3 0x0000555555ca5e38 in Item_func::fix_fields (this=0x7fff500014a8, ... #1 0x0000555555a911dd in Arg_comparator::set_cmp_func (this=0x7fff50001570, #2 0x0000555555c78a23 in Item_func::setup_args_and_comparator ( #3 0x0000555555c78a9b in Item_bool_func2::fix_length_and_dec ( #4 0x0000555555ca5e38 in Item_func::fix_fields (this=0x7fff500014a8, ... #1 0x0000555555a911fc in Arg_comparator::set_cmp_func (this=0x7fff50001570, #2 0x0000555555c78a23 in Item_func::setup_args_and_comparator ( #3 0x0000555555c78a9b in Item_bool_func2::fix_length_and_dec ( #4 0x0000555555ca5e38 in Item_func::fix_fields (this=0x7fff500014a8, ... #1 0x0000555555a6ef54 in check_simple_equality (thd=0x55555a932650, #2 0x0000555555a6f495 in Item_func_eq::check_equality (this=0x7fff500014a8, #3 0x0000555555a6fa77 in Item_func_eq::build_equal_items ( #4 0x0000555555a700e3 in build_equal_items (join=0x7fff50001708, #5 0x0000555555a737af in optimize_cond (join=0x7fff50001708, ... #1 0x0000555555c89292 in Item_equal::Item_equal (this=0x7fff50002228, #2 0x0000555555a6f18e in check_simple_equality (thd=0x55555a932650, #3 0x0000555555a6f495 in Item_func_eq::check_equality (this=0x7fff500014a8, #4 0x0000555555a6fa77 in Item_func_eq::build_equal_items ( #5 0x0000555555a700e3 in build_equal_items (join=0x7fff50001708, #6 0x0000555555a737af in optimize_cond (join=0x7fff50001708, ... #1 0x0000555555c8a114 in Item_equal::fix_length_and_dec (this=0x7fff50002228) #2 0x0000555555c89d79 in Item_equal::fix_fields (this=0x7fff50002228, #3 0x0000555555a6fb38 in Item_func_eq::build_equal_items ( #4 0x0000555555a700e3 in build_equal_items (join=0x7fff50001708, #5 0x0000555555a737af in optimize_cond (join=0x7fff50001708, ... #1 0x0000555555c15e98 in Field::can_optimize_keypart_ref ( #2 0x0000555555a5c649 in add_key_part (keyuse_array=0x7fff50001a10, #3 0x0000555555a5d6bb in update_ref_and_keys (thd=0x55555a932650, #4 0x0000555555a585e6 in make_join_statistics (join=0x7fff50001708, #5 0x0000555555a505fc in JOIN::optimize_inner (this=0x7fff50001708) #6 0x0000555555a4f590 in JOIN::optimize (this=0x7fff50001708) 5 out of 7 calls are done by Item_field 2 out of 7 calls are done by Item_int

              People

              • Assignee:
                bar Alexander Barkov
                Reporter:
                svoj Sergey Vojtovich
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated: