MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / prefetch_prologue

Function prefetch_prologue

src/jrd/cch.cpp:4529–4581  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4527
4528
4529static void prefetch_prologue(Prefetch* prefetch, SLONG* start_page)
4530{
4531/**************************************
4532 *
4533 * p r e f e t c h _ p r o l o g u e
4534 *
4535 **************************************
4536 *
4537 * Functional description
4538 * Search for consecutive pages to be prefetched
4539 * and latch them for I/O.
4540 *
4541 **************************************/
4542 thread_db* tdbb = prefetch->prf_tdbb;
4543 Database* dbb = tdbb->getDatabase();
4544 BufferControl* bcb = dbb->dbb_bcb;
4545
4546 prefetch->prf_start_page = *start_page;
4547 prefetch->prf_page_count = 0;
4548 prefetch->prf_flags |= PRF_active;
4549
4550 BufferDesc** next_bdb = prefetch->prf_bdbs;
4551 for (USHORT i = 0; i < prefetch->prf_max_prefetch; i++)
4552 {
4553 *next_bdb = 0;
4554 if (SBM_clear(bcb->bcb_prefetch, *start_page) &&
4555 (*next_bdb = get_buffer(tdbb, *start_page, LATCH_shared, 0)))
4556 {
4557 if ((*next_bdb)->bdb_flags & BDB_read_pending)
4558 prefetch->prf_page_count = i + 1;
4559 else
4560 {
4561 release_bdb(tdbb, *next_bdb, true, false, false);
4562 *next_bdb = 0;
4563 }
4564 }
4565
4566 next_bdb++;
4567 (*start_page)++;
4568 }
4569
4570 // Optimize non-sequential list prefetching to transfer directly to database buffers.
4571
4572 BufferDesc* bdb;
4573 if (prefetch->prf_page_count == 1 && (bdb = prefetch->prf_bdbs[0]))
4574 prefetch->prf_io_buffer = reinterpret_cast<char*>(bdb->bdb_buffer);
4575 else
4576 prefetch->prf_io_buffer = prefetch->prf_aligned_buffer;
4577
4578 // Reset starting page for next bitmap walk
4579
4580 --(*start_page);
4581}
4582#endif // CACHE_READER
4583
4584

Callers 3

CCH_prefetchFunction · 0.85
cache_readerMethod · 0.85
cache_writerMethod · 0.85

Calls 2

get_bufferFunction · 0.85
getDatabaseMethod · 0.80

Tested by

no test coverage detected