From 7271d16ae8440efa3a236192b9f02294a4148915 Mon Sep 17 00:00:00 2001 From: yahong Date: Sun, 8 Dec 2024 16:48:35 +0900 Subject: [PATCH 1/5] [CBRD-25509] Remove big_length handling from the function, heap_stats_find_best_page. --- src/storage/heap_file.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/storage/heap_file.c b/src/storage/heap_file.c index 0afd46641b3..6ec66cab9c7 100644 --- a/src/storage/heap_file.c +++ b/src/storage/heap_file.c @@ -3567,10 +3567,6 @@ heap_stats_find_best_page (THREAD_ENTRY * thread_p, const HFID * hfid, int neede if (isnew_rec == true) { heap_hdr->estimates.num_recs += 1; - if (newrec_size > DB_PAGESIZE) - { - heap_hdr->estimates.num_pages += CEIL_PTVDIV (newrec_size, DB_PAGESIZE); - } } heap_hdr->estimates.recs_sumlen += (float) newrec_size; From a0f5cbaed0b6919c413d081ffe39dd68a88689ad Mon Sep 17 00:00:00 2001 From: yahong Date: Thu, 12 Dec 2024 22:29:14 +0900 Subject: [PATCH 2/5] [CBRD-25509] Add assert to make sure the previous condition is always false. --- src/storage/heap_file.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/storage/heap_file.c b/src/storage/heap_file.c index 6ec66cab9c7..0338ea4f886 100644 --- a/src/storage/heap_file.c +++ b/src/storage/heap_file.c @@ -3567,6 +3567,8 @@ heap_stats_find_best_page (THREAD_ENTRY * thread_p, const HFID * hfid, int neede if (isnew_rec == true) { heap_hdr->estimates.num_recs += 1; + + assert (!heap_is_big_length (newrec_size)); } heap_hdr->estimates.recs_sumlen += (float) newrec_size; From b6ec5366d4015588e9f13b394edc4d6817594fda Mon Sep 17 00:00:00 2001 From: yahong Date: Mon, 16 Dec 2024 22:43:21 +0900 Subject: [PATCH 3/5] [CBRD-25509] Make assert concisely. --- src/storage/heap_file.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/storage/heap_file.c b/src/storage/heap_file.c index 0338ea4f886..ae135e880e7 100644 --- a/src/storage/heap_file.c +++ b/src/storage/heap_file.c @@ -3564,15 +3564,14 @@ heap_stats_find_best_page (THREAD_ENTRY * thread_p, const HFID * hfid, int neede heap_hdr = (HEAP_HDR_STATS *) hdr_recdes.data; + assert (!heap_is_big_length (needed_space) && !heap_is_big_length (newrec_size)); + if (isnew_rec == true) { heap_hdr->estimates.num_recs += 1; - - assert (!heap_is_big_length (newrec_size)); } heap_hdr->estimates.recs_sumlen += (float) newrec_size; - assert (!heap_is_big_length (needed_space)); /* Take into consideration the unfill factor for pages with objects */ total_space = needed_space + heap_Slotted_overhead + heap_hdr->unfill_space; if (heap_is_big_length (total_space)) From 68d1239a43a7bf0eef59c06a0ddb1f1bc1ab33e8 Mon Sep 17 00:00:00 2001 From: yahong Date: Tue, 24 Dec 2024 15:51:03 +0900 Subject: [PATCH 4/5] [CBRD-25509] Clearn traces. --- src/storage/heap_file.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/storage/heap_file.c b/src/storage/heap_file.c index ae135e880e7..7efea0e55cb 100644 --- a/src/storage/heap_file.c +++ b/src/storage/heap_file.c @@ -627,7 +627,7 @@ static HEAP_FINDSPACE heap_stats_find_page_in_bestspace (THREAD_ENTRY * thread_p int record_length, int needed_space, HEAP_SCANCACHE * scan_cache, PGBUF_WATCHER * pg_watcher); static PAGE_PTR heap_stats_find_best_page (THREAD_ENTRY * thread_p, const HFID * hfid, int needed_space, bool isnew_rec, - int newrec_size, HEAP_SCANCACHE * space_cache, PGBUF_WATCHER * pg_watcher); + HEAP_SCANCACHE * space_cache, PGBUF_WATCHER * pg_watcher); static int heap_stats_sync_bestspace (THREAD_ENTRY * thread_p, const HFID * hfid, HEAP_HDR_STATS * heap_hdr, VPID * hdr_vpid, bool scan_all, bool can_cycle); @@ -3492,8 +3492,8 @@ heap_stats_find_page_in_bestspace (THREAD_ENTRY * thread_p, const HFID * hfid, H * hfid(in): Object heap file identifier * needed_space(in): The minimal space needed * isnew_rec(in): Are we inserting a new record to the heap ? - * newrec_size(in): Size of the new record * scan_cache(in/out): Scan cache used to estimate the best space pages + * pg_watcher(out): watcher for a found page. * * Note: Find a page among the set of best pages of the heap which has * the needed space. If we do not find any page, a new page is @@ -3503,7 +3503,7 @@ heap_stats_find_page_in_bestspace (THREAD_ENTRY * thread_p, const HFID * hfid, H */ static PAGE_PTR heap_stats_find_best_page (THREAD_ENTRY * thread_p, const HFID * hfid, int needed_space, bool isnew_rec, - int newrec_size, HEAP_SCANCACHE * scan_cache, PGBUF_WATCHER * pg_watcher) + HEAP_SCANCACHE * scan_cache, PGBUF_WATCHER * pg_watcher) { VPID vpid; /* Volume and page identifiers */ LOG_DATA_ADDR addr_hdr; /* Address of logging data */ @@ -3564,13 +3564,13 @@ heap_stats_find_best_page (THREAD_ENTRY * thread_p, const HFID * hfid, int neede heap_hdr = (HEAP_HDR_STATS *) hdr_recdes.data; - assert (!heap_is_big_length (needed_space) && !heap_is_big_length (newrec_size)); + assert (!heap_is_big_length (needed_space)); if (isnew_rec == true) { heap_hdr->estimates.num_recs += 1; } - heap_hdr->estimates.recs_sumlen += (float) newrec_size; + heap_hdr->estimates.recs_sumlen += (float) needed_space; /* Take into consideration the unfill factor for pages with objects */ total_space = needed_space + heap_Slotted_overhead + heap_hdr->unfill_space; @@ -20460,13 +20460,13 @@ heap_get_insert_location_with_lock (THREAD_ENTRY * thread_p, HEAP_OPERATION_CONT assert (context != NULL); assert (context->type == HEAP_OPERATION_INSERT); assert (context->recdes_p != NULL); + assert (context->recdes_p->type != REC_NEWHOME); if (home_hint_p == NULL) { /* find and fix page for insert */ if (heap_stats_find_best_page (thread_p, &context->hfid, context->recdes_p->length, - (context->recdes_p->type != REC_NEWHOME), context->recdes_p->length, - context->scan_cache_p, context->home_page_watcher_p) == NULL) + true, context->scan_cache_p, context->home_page_watcher_p) == NULL) { ASSERT_ERROR_AND_SET (error_code); return error_code; @@ -20607,7 +20607,7 @@ heap_find_location_and_insert_rec_newhome (THREAD_ENTRY * thread_p, HEAP_OPERATI } #endif - if (heap_stats_find_best_page (thread_p, &context->hfid, context->recdes_p->length, false, context->recdes_p->length, + if (heap_stats_find_best_page (thread_p, &context->hfid, context->recdes_p->length, false, context->scan_cache_p, context->home_page_watcher_p) == NULL) { ASSERT_ERROR_AND_SET (error_code); From 5fe511d814b39ecfb4dc90b2c1968c7c90b819ad Mon Sep 17 00:00:00 2001 From: yahong Date: Mon, 30 Dec 2024 12:18:19 +0900 Subject: [PATCH 5/5] [CBRD-25509] Make code consistently. --- src/storage/heap_file.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/storage/heap_file.c b/src/storage/heap_file.c index 7efea0e55cb..f1c941b0e9b 100644 --- a/src/storage/heap_file.c +++ b/src/storage/heap_file.c @@ -3518,13 +3518,16 @@ heap_stats_find_best_page (THREAD_ENTRY * thread_p, const HFID * hfid, int neede int error_code = NO_ERROR; PERF_UTIME_TRACKER time_find_best_page = PERF_UTIME_TRACKER_INITIALIZER; + assert (!heap_is_big_length (needed_space)); + assert (scan_cache == NULL || scan_cache->cache_last_fix_page == false || scan_cache->page_watcher.pgptr == NULL); + PERF_UTIME_TRACKER_START (thread_p, &time_find_best_page); + /* * Try to use the space cache for as much information as possible to avoid * fetching and updating the header page a lot. */ - assert (scan_cache == NULL || scan_cache->cache_last_fix_page == false || scan_cache->page_watcher.pgptr == NULL); PGBUF_INIT_WATCHER (&hdr_page_watcher, PGBUF_ORDERED_HEAP_HDR, hfid); /* @@ -3564,8 +3567,6 @@ heap_stats_find_best_page (THREAD_ENTRY * thread_p, const HFID * hfid, int neede heap_hdr = (HEAP_HDR_STATS *) hdr_recdes.data; - assert (!heap_is_big_length (needed_space)); - if (isnew_rec == true) { heap_hdr->estimates.num_recs += 1;