int ImageSpecClass::LeadTimeForChipSize() const { int totalMem = totalMemOnTorrentServer(); if ( totalMem > ( 24*1024*1024 ) ) { if ( ( rows * cols ) > 10000000 ) return ( 8 ); // 318 if ( ( rows * cols ) > 2000000 ) return ( 10 ); // 316 else return ( 21 ); } else { if ( ( rows * cols ) > 10000000 ) return ( 2 ); // 318 if ( ( rows * cols ) > 2000000 ) return ( 4 ); // 316 else return ( 21 ); } }
void ImageTracker::DecideOnRawDatsToBufferForThisFlowBlock() { // need dynamic read ahead every 20 block of flows for 318 chips if (ChipIdDecoder::GetGlobalChipId() == ChipId318) { static int readahead = master_img_loader.lead; const double allowedFreeRatio = 0.2; double freeSystemMemory = GetAbsoluteFreeSystemMemoryInKB() / (1024.0*1024.0); double totalSystemMemory = (double)(totalMemOnTorrentServer()) / (1024.0*1024.0); double freeRatio = freeSystemMemory / totalSystemMemory; if (freeRatio < allowedFreeRatio) master_img_loader.lead = 1; else if (freeRatio < 0.3) master_img_loader.lead = 2; else if (freeRatio < 0.6) master_img_loader.lead = 4; else master_img_loader.lead = readahead; printf("TotalMem: %f FreeMem: %f Free/total Ratio: %f Allowed Free/total Ratio: %f readahead: %d\n", totalSystemMemory, freeSystemMemory, freeRatio, allowedFreeRatio, master_img_loader.lead); fflush(stdout); } }