MCPcopy Create free account
hub / github.com/apache/cloudberry / BitmapAdjustPrefetchTarget

Function BitmapAdjustPrefetchTarget

src/backend/executor/nodeBitmapHeapscan.c:477–511  ·  view source on GitHub ↗

* BitmapAdjustPrefetchTarget - Adjust the prefetch target * * Increase prefetch target if it's not yet at the max. Note that * we will increase it to zero after fetching the very first * page/tuple, then to one after the second tuple is fetched, then * it doubles as later pages are fetched. */

Source from the content-addressed store, hash-verified

475 * it doubles as later pages are fetched.
476 */
477static inline void
478BitmapAdjustPrefetchTarget(BitmapHeapScanState *node)
479{
480#ifdef USE_PREFETCH
481 ParallelBitmapHeapState *pstate = node->pstate;
482
483 if (pstate == NULL)
484 {
485 if (node->prefetch_target >= node->prefetch_maximum)
486 /* don't increase any further */ ;
487 else if (node->prefetch_target >= node->prefetch_maximum / 2)
488 node->prefetch_target = node->prefetch_maximum;
489 else if (node->prefetch_target > 0)
490 node->prefetch_target *= 2;
491 else
492 node->prefetch_target++;
493 return;
494 }
495
496 /* Do an unlocked check first to save spinlock acquisitions. */
497 if (pstate->prefetch_target < node->prefetch_maximum)
498 {
499 SpinLockAcquire(&pstate->mutex);
500 if (pstate->prefetch_target >= node->prefetch_maximum)
501 /* don't increase any further */ ;
502 else if (pstate->prefetch_target >= node->prefetch_maximum / 2)
503 pstate->prefetch_target = node->prefetch_maximum;
504 else if (pstate->prefetch_target > 0)
505 pstate->prefetch_target *= 2;
506 else
507 pstate->prefetch_target++;
508 SpinLockRelease(&pstate->mutex);
509 }
510#endif /* USE_PREFETCH */
511}
512
513/*
514 * BitmapPrefetch - Prefetch, if prefetch_pages are behind prefetch_target

Callers 1

BitmapHeapNextFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected