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

Function CCH_prefetch

src/jrd/cch.cpp:1849–1904  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1847
1848#ifdef CACHE_READER
1849void CCH_prefetch(thread_db* tdbb, SLONG* pages, SSHORT count)
1850{
1851/**************************************
1852 *
1853 * C C H _ p r e f e t c h
1854 *
1855 **************************************
1856 *
1857 * Functional description
1858 * Given a vector of pages, set corresponding bits
1859 * in global prefetch bitmap. Initiate an asynchronous
1860 * I/O and get the cache reader reading in our behalf
1861 * as well.
1862 *
1863 **************************************/
1864 SET_TDBB(tdbb);
1865 Database* dbb = tdbb->getDatabase();
1866 BufferControl* bcb = dbb->dbb_bcb;
1867
1868 if (!count || !(bcb->bcb_flags & BCB_cache_reader))
1869 {
1870 // Caller isn't really serious.
1871 return;
1872 }
1873
1874 // Switch default pool to permanent pool for setting bits in prefetch bitmap.
1875 Jrd::ContextPoolHolder context(tdbb, bcb->bcb_bufferpool);
1876
1877 // The global prefetch bitmap is the key to the I/O coalescense mechanism which dovetails
1878 // all thread prefetch requests to minimize sequential I/O requests.
1879 // It also enables multipage I/O by implicitly sorting page vector requests.
1880
1881 SLONG first_page = 0;
1882 for (const SLONG* const end = pages + count; pages < end;)
1883 {
1884 const SLONG page = *pages++;
1885 if (page)
1886 {
1887 SBM_set(tdbb, &bcb->bcb_prefetch, page);
1888 if (!first_page)
1889 first_page = page;
1890 }
1891 }
1892
1893 // Not likely that the caller's page vector was empty but check anyway.
1894
1895 if (first_page)
1896 {
1897 prf prefetch;
1898
1899 prefetch_init(&prefetch, tdbb);
1900 prefetch_prologue(&prefetch, &first_page);
1901 prefetch_io(&prefetch, tdbb->tdbb_status_vector);
1902 prefetch_epilogue(&prefetch, tdbb->tdbb_status_vector);
1903 }
1904}
1905
1906

Callers 1

CCH_PREFETCHFunction · 0.85

Calls 6

SET_TDBBFunction · 0.85
prefetch_initFunction · 0.85
prefetch_prologueFunction · 0.85
prefetch_ioFunction · 0.85
prefetch_epilogueFunction · 0.85
getDatabaseMethod · 0.80

Tested by

no test coverage detected