Commit 143f5d91 authored by Jan Lindström's avatar Jan Lindström

MDEV-7061: Augment innochecksum to give insight of fragmentation

Merged https://github.com/facebook/mysql-5.6/commit/615dd07d900ce08948340b6c11e37fd1d2a91065 from https://github.com/facebook/mysql-5.6/
authored by rongrong. Removed C++11 requirement by using
std::map instead of std::unordered_set.

Add analysis to leaf pages to estimate how fragmented an index is
and how much benefit we can get out of defragmentation.
parent 2e4dc5a3
This diff is collapsed.
...@@ -15,17 +15,8 @@ INSERT INTO t3(b) SELECT b from t1; ...@@ -15,17 +15,8 @@ INSERT INTO t3(b) SELECT b from t1;
# We want SQL to initiate the first access to t1.ibd. # We want SQL to initiate the first access to t1.ibd.
# Wait until disconnected. # Wait until disconnected.
# Run innochecksum on t1 # Run innochecksum on t1
InnoDB offline file checksum utility.
Table is uncompressed
Page size is 16384
# Run innochecksum on t2 # Run innochecksum on t2
InnoDB offline file checksum utility.
Table is compressed
Key block size is 8192
# Run innochecksum on t3 # Run innochecksum on t3
InnoDB offline file checksum utility.
Table is compressed
Key block size is 16384
# Write file to make mysql-test-run.pl start up the server again # Write file to make mysql-test-run.pl start up the server again
# Cleanup # Cleanup
DROP TABLE t1, t2, t3; DROP TABLE t1, t2, t3;
...@@ -53,13 +53,17 @@ shutdown_server 30; ...@@ -53,13 +53,17 @@ shutdown_server 30;
--source include/wait_until_disconnected.inc --source include/wait_until_disconnected.inc
--echo # Run innochecksum on t1 --echo # Run innochecksum on t1
-- disable_result_log
--exec $INNOCHECKSUM $t1_IBD --exec $INNOCHECKSUM $t1_IBD
--echo # Run innochecksum on t2 --echo # Run innochecksum on t2
--exec $INNOCHECKSUM $t2_IBD --exec $INNOCHECKSUM $t2_IBD
--echo # Run innochecksum on t3 --echo # Run innochecksum on t3
--exec $INNOCHECKSUM $t3_IBD --exec $INNOCHECKSUM $t3_IBD
--enable_result_log
--echo # Write file to make mysql-test-run.pl start up the server again --echo # Write file to make mysql-test-run.pl start up the server again
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
......
...@@ -29,13 +29,14 @@ Created 12/18/1995 Heikki Tuuri ...@@ -29,13 +29,14 @@ Created 12/18/1995 Heikki Tuuri
#include "univ.i" #include "univ.i"
#include "fsp0types.h"
#ifndef UNIV_INNOCHECKSUM #ifndef UNIV_INNOCHECKSUM
#include "mtr0mtr.h" #include "mtr0mtr.h"
#include "fut0lst.h" #include "fut0lst.h"
#include "ut0byte.h" #include "ut0byte.h"
#include "page0types.h" #include "page0types.h"
#include "fsp0types.h"
#endif /* !UNIV_INNOCHECKSUM */ #endif /* !UNIV_INNOCHECKSUM */
...@@ -294,7 +295,6 @@ descriptor page, but used only in the first. */ ...@@ -294,7 +295,6 @@ descriptor page, but used only in the first. */
FSP_FREE_LIMIT at a time */ FSP_FREE_LIMIT at a time */
/* @} */ /* @} */
#ifndef UNIV_INNOCHECKSUM
/* @defgroup File Segment Inode Constants (moved from fsp0fsp.c) @{ */ /* @defgroup File Segment Inode Constants (moved from fsp0fsp.c) @{ */
...@@ -432,6 +432,7 @@ the extent are free and which contain old tuple version to clean. */ ...@@ -432,6 +432,7 @@ the extent are free and which contain old tuple version to clean. */
/* @} */ /* @} */
#ifndef UNIV_INNOCHECKSUM
/**********************************************************************//** /**********************************************************************//**
Initializes the file space system. */ Initializes the file space system. */
UNIV_INTERN UNIV_INTERN
......
...@@ -275,6 +275,7 @@ xdes_calc_descriptor_index( ...@@ -275,6 +275,7 @@ xdes_calc_descriptor_index(
return(ut_2pow_remainder(offset, zip_size) / FSP_EXTENT_SIZE); return(ut_2pow_remainder(offset, zip_size) / FSP_EXTENT_SIZE);
} }
} }
#endif /* !UNIV_INNOCHECKSUM */
/**********************************************************************//** /**********************************************************************//**
Gets a descriptor bit of a page. Gets a descriptor bit of a page.
...@@ -302,6 +303,7 @@ xdes_get_bit( ...@@ -302,6 +303,7 @@ xdes_get_bit(
bit_index)); bit_index));
} }
#ifndef UNIV_INNOCHECKSUM
/********************************************************************//** /********************************************************************//**
Calculates the page where the descriptor of a page resides. Calculates the page where the descriptor of a page resides.
@return descriptor page offset */ @return descriptor page offset */
......
...@@ -42,6 +42,7 @@ mach_write_to_1( ...@@ -42,6 +42,7 @@ mach_write_to_1(
b[0] = (byte) n; b[0] = (byte) n;
} }
#endif /* !UNIV_INNOCHECKSUM */
/********************************************************//** /********************************************************//**
The following function is used to fetch data from one byte. The following function is used to fetch data from one byte.
...@@ -73,8 +74,6 @@ mach_write_to_2( ...@@ -73,8 +74,6 @@ mach_write_to_2(
b[1] = (byte)(n); b[1] = (byte)(n);
} }
#endif /* !UNIV_INNOCHECKSUM */
/********************************************************//** /********************************************************//**
The following function is used to fetch data from 2 consecutive The following function is used to fetch data from 2 consecutive
bytes. The most significant byte is at the lowest address. bytes. The most significant byte is at the lowest address.
...@@ -860,7 +859,10 @@ mach_write_ulonglong( ...@@ -860,7 +859,10 @@ mach_write_ulonglong(
*dest ^= 0x80; *dest ^= 0x80;
} }
} }
#endif /* !UNIV_HOTBACKUP */
#endif /* !UNIV_INNOCHECKSUM */
#ifndef UNIV_HOTBACKUP
/********************************************************//** /********************************************************//**
Reads 1 - 4 bytes from a file page buffered in the buffer pool. Reads 1 - 4 bytes from a file page buffered in the buffer pool.
@return value read */ @return value read */
...@@ -886,4 +888,3 @@ mach_read_ulint( ...@@ -886,4 +888,3 @@ mach_read_ulint(
} }
#endif /* !UNIV_HOTBACKUP */ #endif /* !UNIV_HOTBACKUP */
#endif /* !UNIV_INNOCHECKSUM */
...@@ -224,12 +224,15 @@ ut_2_power_up( ...@@ -224,12 +224,15 @@ ut_2_power_up(
ulint n) /*!< in: number != 0 */ ulint n) /*!< in: number != 0 */
__attribute__((const)); __attribute__((const));
#endif /* !UNIV_INNOCHECKSUM */
/** Determine how many bytes (groups of 8 bits) are needed to /** Determine how many bytes (groups of 8 bits) are needed to
store the given number of bits. store the given number of bits.
@param b in: bits @param b in: bits
@return number of bytes (octets) needed to represent b */ @return number of bytes (octets) needed to represent b */
#define UT_BITS_IN_BYTES(b) (((b) + 7) / 8) #define UT_BITS_IN_BYTES(b) (((b) + 7) / 8)
#ifndef UNIV_INNOCHECKSUM
/**********************************************************//** /**********************************************************//**
Returns system time. We do not specify the format of the time returned: Returns system time. We do not specify the format of the time returned:
the only way to manipulate it is to use the function ut_difftime. the only way to manipulate it is to use the function ut_difftime.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment