Skip to content

Commit

Permalink
Fix locking of prfetch score.
Browse files Browse the repository at this point in the history
  • Loading branch information
alja committed Aug 18, 2016
1 parent 1a29741 commit a612a18
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 30 deletions.
38 changes: 11 additions & 27 deletions src/XrdFileCache/XrdFileCacheFile.cc
Expand Up @@ -431,8 +431,6 @@ int File::ReadBlocksFromDisk(std::list<int>& blocks,
}

total += rs;

CheckPrefetchStatDisk(*ii);
}

m_stats.m_BytesDisk += total;
Expand Down Expand Up @@ -572,6 +570,7 @@ int File::Read(char* iUserBuff, long long iUserOff, int iUserSize)
}

// Third, loop over blocks that are available or incoming
int prefetchHitsRam = 0;
while ( ! blks_to_process.empty() && bytes_read >= 0)
{
BlockList_t finished;
Expand Down Expand Up @@ -618,7 +617,8 @@ int File::Read(char* iUserBuff, long long iUserOff, int iUserSize)
memcpy(&iUserBuff[user_off], &((*bi)->m_buff[off_in_block]), size_to_copy);
bytes_read += size_to_copy;
m_stats.m_BytesRam += size_to_copy;
CheckPrefetchStatRAM(*bi);
if ((*bi)->m_prefetch)
prefetchHitsRam++;
}
else // it has failed ... krap up.
{
Expand Down Expand Up @@ -676,6 +676,14 @@ int File::Read(char* iUserBuff, long long iUserOff, int iUserSize)
dec_ref_count(*bi);
// XXXX stamp block
}

// update prefetch score
m_prefetchHitCnt += prefetchHitsRam;
for (IntList_i d = blks_on_disk.begin(); d != blks_on_disk.end(); ++d) {
if (m_cfi.TestPrefetchBit(offsetIdx(*d)))
m_prefetchHitCnt++;
}
m_prefetchScore = float(m_prefetchHitCnt)/m_prefetchReadCnt;
}

return bytes_read;
Expand Down Expand Up @@ -941,30 +949,6 @@ void File::Prefetch()
}
}

//------------------------------------------------------------------------------

void File::CheckPrefetchStatRAM(Block* b)
{
if (Cache::GetInstance().RefConfiguration().m_prefetch_max_blocks)
{
if (b->m_prefetch)
{
m_prefetchHitCnt++;
m_prefetchScore = float(m_prefetchHitCnt)/m_prefetchReadCnt;
}
}
}

//------------------------------------------------------------------------------

void File::CheckPrefetchStatDisk(int idx)
{
if (Cache::GetInstance().RefConfiguration().m_prefetch_max_blocks)
{
if (m_cfi.TestPrefetchBit(offsetIdx(idx)))
m_prefetchHitCnt++;
}
}

//------------------------------------------------------------------------------

Expand Down
3 changes: 0 additions & 3 deletions src/XrdFileCache/XrdFileCacheFile.hh
Expand Up @@ -231,9 +231,6 @@ namespace XrdFileCache
long long BufferSize();
void AppendIOStatToFileInfo();

void CheckPrefetchStatRAM(Block* b);
void CheckPrefetchStatDisk(int idx);

void inc_ref_count(Block*);
void dec_ref_count(Block*);
void free_block(Block*);
Expand Down

0 comments on commit a612a18

Please sign in to comment.