Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add counters for successful page merges and page discards

Currently Innodb_page_merges counts only merge attempts but there is
no metric for successful merges. This change introduces a new status
variable named Innodb_page_merges_succeeded which indicates the number
of successful page merge operations (that is, the number of pages
successfully merged into another page).

Additionally, this change also introduces a new status variable named
Innodb_page_discards which represents the number of pages that have
become empty and are thus discarded.
  • Loading branch information...
commit a54c930106e4ded728a25efed6c39564d3545a07 1 parent e33eab4
Davi Arnaut authored
View
26 mysql-test/suite/innodb/r/innodb_status.result
@@ -143,6 +143,8 @@ INSERT INTO t1 VALUES(3, REPEAT('b', 2048), REPEAT('c', 2048));
INSERT INTO t1 VALUES(4, REPEAT('b', 2048), REPEAT('c', 2048));
SELECT VARIABLE_VALUE INTO @page_merges_1 FROM gsv WHERE
VARIABLE_NAME = 'INNODB_PAGE_MERGES';
+SELECT VARIABLE_VALUE INTO @page_merges_succ_1 FROM gsv WHERE
+VARIABLE_NAME = 'INNODB_PAGE_MERGES_SUCCEEDED';
SELECT VARIABLE_VALUE INTO @page_reorganizes_1 FROM gsv WHERE
VARIABLE_NAME = 'INNODB_PAGE_REORGANIZES';
#
@@ -154,6 +156,8 @@ UPDATE t1 SET b = 'b', c = 'c' WHERE a = 3;
UPDATE t1 SET b = 'b', c = 'c' WHERE a = 4;
SELECT VARIABLE_VALUE INTO @page_merges_2 FROM gsv WHERE
VARIABLE_NAME = 'INNODB_PAGE_MERGES';
+SELECT VARIABLE_VALUE INTO @page_merges_succ_2 FROM gsv WHERE
+VARIABLE_NAME = 'INNODB_PAGE_MERGES_SUCCEEDED';
SELECT VARIABLE_VALUE INTO @page_reorganizes_2 FROM gsv WHERE
VARIABLE_NAME = 'INNODB_PAGE_REORGANIZES';
SELECT VARIABLE_VALUE INTO @page_splits_2 FROM gsv WHERE
@@ -165,6 +169,9 @@ VARIABLE_NAME = 'INNODB_PAGE_SPLITS';
SELECT (@page_merges_2 - @page_merges_1) AS 'INNODB_PAGE_MERGES';
INNODB_PAGE_MERGES
1
+SELECT (@page_merges_succ_2 - @page_merges_succ_1) AS 'INNODB_PAGE_MERGES_SUCCEEDED';
+INNODB_PAGE_MERGES_SUCCEEDED
+1
SELECT (@page_reorganizes_2 - @page_reorganizes_1) AS 'INNODB_PAGE_REORGANIZES';
INNODB_PAGE_REORGANIZES
1
@@ -213,6 +220,25 @@ ROLLBACK;
DROP TABLE t1;
SET GLOBAL innodb_change_buffering_debug = @old_innodb_change_buffering_debug;
#
+# Add counters for page_merges_succeeded and page_discards
+#
+CREATE TABLE t1 (a BIGINT AUTO_INCREMENT PRIMARY KEY, b VARCHAR(2048),
+c VARCHAR(2048)) ENGINE=InnoDB;
+# Populate table with a few pages worth of data.
+INSERT INTO t1 VALUES(1, REPEAT('b', 2048), REPEAT('c', 2048));
+INSERT INTO t1 SELECT 0,b,c FROM t1;
+INSERT INTO t1 SELECT 0,b,c FROM t1;
+INSERT INTO t1 SELECT 0,b,c FROM t1;
+INSERT INTO t1 SELECT 0,b,c FROM t1;
+# Collect status values for later comparison.
+SELECT VARIABLE_VALUE INTO @page_discard FROM gsv WHERE
+VARIABLE_NAME = 'INNODB_PAGE_DISCARD';
+# Delete all records from the right-most page.
+DELETE FROM t1 WHERE a > 17 ORDER BY a;
+# Wait for records to be purged.
+# Wait for the page_discard status value to be updated.
+DROP TABLE t1;
+#
# Cleanup
#
SET GLOBAL innodb_file_per_table = @old_innodb_file_per_table;
View
42 mysql-test/suite/innodb/t/innodb_status.test
@@ -195,6 +195,9 @@ INSERT INTO t1 VALUES(4, REPEAT('b', 2048), REPEAT('c', 2048));
SELECT VARIABLE_VALUE INTO @page_merges_1 FROM gsv WHERE
VARIABLE_NAME = 'INNODB_PAGE_MERGES';
+SELECT VARIABLE_VALUE INTO @page_merges_succ_1 FROM gsv WHERE
+ VARIABLE_NAME = 'INNODB_PAGE_MERGES_SUCCEEDED';
+
SELECT VARIABLE_VALUE INTO @page_reorganizes_1 FROM gsv WHERE
VARIABLE_NAME = 'INNODB_PAGE_REORGANIZES';
@@ -209,6 +212,8 @@ UPDATE t1 SET b = 'b', c = 'c' WHERE a = 4;
SELECT VARIABLE_VALUE INTO @page_merges_2 FROM gsv WHERE
VARIABLE_NAME = 'INNODB_PAGE_MERGES';
+SELECT VARIABLE_VALUE INTO @page_merges_succ_2 FROM gsv WHERE
+ VARIABLE_NAME = 'INNODB_PAGE_MERGES_SUCCEEDED';
SELECT VARIABLE_VALUE INTO @page_reorganizes_2 FROM gsv WHERE
VARIABLE_NAME = 'INNODB_PAGE_REORGANIZES';
SELECT VARIABLE_VALUE INTO @page_splits_2 FROM gsv WHERE
@@ -220,6 +225,7 @@ SELECT VARIABLE_VALUE INTO @page_splits_2 FROM gsv WHERE
--echo #
SELECT (@page_merges_2 - @page_merges_1) AS 'INNODB_PAGE_MERGES';
+SELECT (@page_merges_succ_2 - @page_merges_succ_1) AS 'INNODB_PAGE_MERGES_SUCCEEDED';
SELECT (@page_reorganizes_2 - @page_reorganizes_1) AS 'INNODB_PAGE_REORGANIZES';
SELECT (@page_splits_2 - @page_splits_1) AS 'INNODB_PAGE_SPLITS';
@@ -288,6 +294,42 @@ DROP TABLE t1;
SET GLOBAL innodb_change_buffering_debug = @old_innodb_change_buffering_debug;
--echo #
+--echo # Add counters for page_merges_succeeded and page_discards
+--echo #
+
+CREATE TABLE t1 (a BIGINT AUTO_INCREMENT PRIMARY KEY, b VARCHAR(2048),
+ c VARCHAR(2048)) ENGINE=InnoDB;
+
+--echo # Populate table with a few pages worth of data.
+INSERT INTO t1 VALUES(1, REPEAT('b', 2048), REPEAT('c', 2048));
+INSERT INTO t1 SELECT 0,b,c FROM t1;
+INSERT INTO t1 SELECT 0,b,c FROM t1;
+INSERT INTO t1 SELECT 0,b,c FROM t1;
+INSERT INTO t1 SELECT 0,b,c FROM t1;
+
+--echo # Collect status values for later comparison.
+SELECT VARIABLE_VALUE INTO @page_discard FROM gsv WHERE
+ VARIABLE_NAME = 'INNODB_PAGE_DISCARD';
+
+--echo # Delete all records from the right-most page.
+DELETE FROM t1 WHERE a > 17 ORDER BY a;
+
+--echo # Wait for records to be purged.
+let $wait_condition = SELECT COUNT(*) = 1 FROM gsv WHERE VARIABLE_NAME =
+ 'INNODB_PURGE_TRX_NO' AND VARIABLE_VALUE = (SELECT VARIABLE_VALUE FROM
+ gsv WHERE VARIABLE_NAME = 'INNODB_TRX_MAX_ID');
+--source include/wait_condition.inc
+
+--echo # Wait for the page_discard status value to be updated.
+let $wait_condition=
+ SELECT COUNT(*) > 0 FROM gsv WHERE
+ VARIABLE_NAME = 'INNODB_PAGE_DISCARD' AND
+ VARIABLE_VALUE > @page_discard;
+--source include/wait_condition.inc
+
+DROP TABLE t1;
+
+--echo #
--echo # Cleanup
--echo #
View
8 storage/innobase/btr/btr0btr.c
@@ -50,6 +50,10 @@ UNIV_INTERN ulint btr_n_page_reorganize = 0;
UNIV_INTERN ulint btr_n_page_split = 0;
/** Number of page merge operations. */
UNIV_INTERN ulint btr_n_page_merge = 0;
+/** Number of successful page merge operations. */
+UNIV_INTERN ulint btr_n_page_merge_succ = 0;
+/** Number of page discard operations. */
+UNIV_INTERN ulint btr_n_page_discard = 0;
/**************************************************************//**
Report that an index page is corrupted. */
@@ -3567,6 +3571,8 @@ btr_compress(
merge_block, cursor);
}
+ btr_n_page_merge_succ++;
+
return(TRUE);
}
@@ -3666,6 +3672,8 @@ btr_discard_page(
page_t* page;
rec_t* node_ptr;
+ btr_n_page_discard++;
+
block = btr_cur_get_block(cursor);
index = btr_cur_get_index(cursor);
View
4 storage/innobase/handler/ha_innodb.cc
@@ -788,8 +788,12 @@ static SHOW_VAR innodb_status_variables[]= {
(char*) &export_vars.innodb_os_log_pending_writes, SHOW_LONG},
{"os_log_written",
(char*) &export_vars.innodb_os_log_written, SHOW_LONG},
+ {"page_discard",
+ (char*) &export_vars.innodb_btree_page_discard, SHOW_LONG},
{"page_merges",
(char*) &export_vars.innodb_btree_page_merge, SHOW_LONG},
+ {"page_merges_succeeded",
+ (char*) &export_vars.innodb_btree_page_merge_succ, SHOW_LONG},
{"page_reorganizes",
(char*) &export_vars.innodb_btree_page_reorganize, SHOW_LONG},
{"page_size",
View
4 storage/innobase/include/btr0btr.h
@@ -694,6 +694,10 @@ extern ulint btr_n_page_reorganize;
extern ulint btr_n_page_split;
/** Number of page merge operations. */
extern ulint btr_n_page_merge;
+/** Number of successful page merge operations. */
+extern ulint btr_n_page_merge_succ;
+/** Number of page discard operations. */
+extern ulint btr_n_page_discard;
#endif /* !UNIV_HOTBACKUP */
View
2  storage/innobase/include/srv0srv.h
@@ -847,6 +847,8 @@ struct export_var_struct{
ulint innodb_btree_page_reorganize; /*!< btr_n_page_reorganize */
ulint innodb_btree_page_split; /*!< btr_n_page_split */
ulint innodb_btree_page_merge; /*!< btr_n_page_merge */
+ ulint innodb_btree_page_merge_succ; /*!< btr_n_page_merge_succ */
+ ulint innodb_btree_page_discard; /*!< btr_n_page_discard */
ib_uint64_t innodb_trx_max_id; /*!< trx_sys->max_trx_id */
ib_uint64_t innodb_purge_trx_no; /*!< purge_sys->purge_trx_no */
ib_uint64_t innodb_purge_undo_no; /*!< purge_sys->purge_undo_no */
View
2  storage/innobase/srv/srv0srv.c
@@ -2217,6 +2217,8 @@ srv_export_innodb_status(void)
export_vars.innodb_btree_page_reorganize = btr_n_page_reorganize;
export_vars.innodb_btree_page_split = btr_n_page_split;
export_vars.innodb_btree_page_merge = btr_n_page_merge;
+ export_vars.innodb_btree_page_merge_succ = btr_n_page_merge_succ;
+ export_vars.innodb_btree_page_discard = btr_n_page_discard;
export_vars.innodb_trx_max_id = trx_sys->max_trx_id;
export_vars.innodb_purge_trx_no = purge_sys->purge_trx_no;
Please sign in to comment.
Something went wrong with that request. Please try again.