#At file:///home/svoj/devel/innodb-snapshots/mysql-5.1-bugteam/ based on revid:svoj@stripped
3497 Sergey Vojtovich 2010-04-01
Applying InnoDB snapshot, fixes BUG#49535.
Detailed revision comments:
r6674 | inaam | 2010-02-11 17:54:44 +0200 (Thu, 11 Feb 2010) | 16 lines
branches/zip bug# 49535
This is a backport of r4924.
mem_heap_get_size() scans all allocated blocks to calculate the total
size of the heap. This patch introduces a new, total_size, field in
mem_block_info_struct. This field is valid only for base block
(i.e.: the first block allocated for the heap) and is set to
ULINT_UNDEFINED in other blocks.
This considerably improves the performance of redo scan during recovery.
rb://108 issue#216
Approved by: Heikki
modified:
storage/innodb_plugin/include/mem0mem.h
storage/innodb_plugin/include/mem0mem.ic
storage/innodb_plugin/mem/mem0mem.c
=== modified file 'storage/innodb_plugin/include/mem0mem.h'
--- a/storage/innodb_plugin/include/mem0mem.h 2009-11-30 11:32:05 +0000
+++ b/storage/innodb_plugin/include/mem0mem.h 2010-04-01 11:52:35 +0000
@@ -359,6 +359,9 @@ struct mem_block_info_struct {
to the heap is also the first block in this list,
though it also contains the base node of the list. */
ulint len; /*!< physical length of this block in bytes */
+ ulint total_size; /* physical length in bytes of all blocks
+ in the heap. This is defined only in the base
+ node and is set to ULINT_UNDEFINED in others. */
ulint type; /*!< type of heap: MEM_HEAP_DYNAMIC, or
MEM_HEAP_BUF possibly ORed to MEM_HEAP_BTR_SEARCH */
ulint free; /*!< offset in bytes of the first free position for
=== modified file 'storage/innodb_plugin/include/mem0mem.ic'
--- a/storage/innodb_plugin/include/mem0mem.ic 2009-05-27 09:45:59 +0000
+++ b/storage/innodb_plugin/include/mem0mem.ic 2010-04-01 11:52:35 +0000
@@ -579,18 +579,12 @@ mem_heap_get_size(
/*==============*/
mem_heap_t* heap) /*!< in: heap */
{
- mem_block_t* block;
ulint size = 0;
ut_ad(mem_heap_check(heap));
- block = heap;
+ size = heap->total_size;
- while (block != NULL) {
-
- size += mem_block_get_len(block);
- block = UT_LIST_GET_NEXT(list, block);
- }
#ifndef UNIV_HOTBACKUP
if (heap->free_block) {
size += UNIV_PAGE_SIZE;
=== modified file 'storage/innodb_plugin/mem/mem0mem.c'
--- a/storage/innodb_plugin/mem/mem0mem.c 2009-10-08 10:00:49 +0000
+++ b/storage/innodb_plugin/mem/mem0mem.c 2010-04-01 11:52:35 +0000
@@ -383,6 +383,20 @@ mem_heap_create_block(
mem_block_set_free(block, MEM_BLOCK_HEADER_SIZE);
mem_block_set_start(block, MEM_BLOCK_HEADER_SIZE);
+ if (UNIV_UNLIKELY(heap == NULL)) {
+ /* This is the first block of the heap. The field
+ total_size should be initialized here */
+ block->total_size = len;
+ } else {
+ /* Not the first allocation for the heap. This block's
+ total_length field should be set to undefined. */
+ ut_d(block->total_size = ULINT_UNDEFINED);
+ UNIV_MEM_INVALID(&block->total_size,
+ sizeof block->total_size);
+
+ heap->total_size += len;
+ }
+
ut_ad((ulint)MEM_BLOCK_HEADER_SIZE < len);
return(block);
@@ -471,6 +485,10 @@ mem_heap_block_free(
mem_pool_mutex_exit();
#endif
+
+ ut_ad(heap->total_size >= block->len);
+ heap->total_size -= block->len;
+
type = heap->type;
len = block->len;
block->magic_n = MEM_FREED_BLOCK_MAGIC_N;
Attachment: [text/bzr-bundle] bzr/svoj@sun.com-20100401115235-pau8xa6zohz0hj57.bundle
| Thread |
|---|
| • bzr commit into mysql-5.1-bugteam branch (svoj:3497) Bug#49535 | Sergey Vojtovich | 1 Apr |