Skip to content

Commit

Permalink
Store access statistics in bytes instead of number of blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
alja authored and abh3 committed Jun 30, 2016
1 parent 2c6370a commit fd98b55
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/XrdFileCache/XrdFileCacheFile.cc
Expand Up @@ -421,10 +421,10 @@ int File::ReadBlocksFromDisk(std::list<int>& blocks,

total += rs;


CheckPrefetchStatDisk(*ii);
}

m_stats.m_BytesDisk += total;
return total;
}

Expand Down Expand Up @@ -468,14 +468,12 @@ int File::Read(char* iUserBuff, long long iUserOff, int iUserSize)
inc_ref_count(bi->second);
TRACEF(Dump, "File::Read() " << iUserBuff << "inc_ref_count for existing block << " << bi->second << " idx = " << block_idx);
blks_to_process.push_front(bi->second);
m_stats.m_BytesRam++; // AMT what if block fails
}
// On disk?
else if (m_cfi.TestBit(offsetIdx(block_idx)))
{
TRACEF(Dump, "File::Read() read from disk " << (void*)iUserBuff << " idx = " << block_idx);
blks_on_disk.push_back(block_idx);
m_stats.m_BytesDisk++;
}
// Then we have to get it ...
else
Expand All @@ -492,14 +490,12 @@ int File::Read(char* iUserBuff, long long iUserOff, int iUserSize)
}
inc_ref_count(b);
blks_to_process.push_back(b);
m_stats.m_BytesRam++;
}
// Nope ... read this directly without caching.
else
{
TRACEF(Dump, "File::Read() direct block " << block_idx);
blks_direct.push_back(block_idx);
m_stats.m_BytesMissed++;
}
}

Expand Down Expand Up @@ -604,7 +600,7 @@ int File::Read(char* iUserBuff, long long iUserOff, int iUserSize)
TRACEF(Dump, "File::Read() ub=" << (void*)iUserBuff << " from finished block " << (*bi)->m_offset/BS << " size " << size_to_copy);
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);
}
else // it has failed ... krap up.
Expand Down Expand Up @@ -635,6 +631,7 @@ int File::Read(char* iUserBuff, long long iUserOff, int iUserSize)
if (direct_handler->m_errno == 0)
{
bytes_read += direct_size;
m_stats.m_BytesMissed += direct_size;
}
else
{
Expand Down
5 changes: 5 additions & 0 deletions src/XrdFileCache/XrdFileCacheVRead.cc
Expand Up @@ -125,7 +125,10 @@ int File::ReadV (const XrdOucIOVec *readV, int n)
if (direct_handler->m_errno == 0)
{
for (std::vector<XrdOucIOVec>::iterator i = chunkVec.begin(); i != chunkVec.end(); ++i)
{
bytesRead += i->size;
m_stats.m_BytesMissed += i->size;
}
}
else
{
Expand Down Expand Up @@ -234,6 +237,7 @@ int File::VReadFromDisk(const XrdOucIOVec *readV, int n, ReadVBlockListDisk& blo
int rs = m_output->Read(readV[chunkIdx].data + off, blockIdx*m_cfi.GetBufferSize() + blk_off - m_offset, size);
if (rs >=0 ) {
bytes_read += rs;
m_stats.m_BytesDisk += rs;
}
else {
// ofs read should set the errno
Expand Down Expand Up @@ -295,6 +299,7 @@ int File::VReadProcessBlocks(const XrdOucIOVec *readV, int n,
overlap(block_idx, m_cfi.GetBufferSize(), readV[*chunkIt].offset, readV[*chunkIt].size, off, blk_off, size);
memcpy(readV[*chunkIt].data + off, &(bi->block->m_buff[blk_off]), size);
bytes_read += size;
m_stats.m_BytesRam += size;
}
}
else {
Expand Down

0 comments on commit fd98b55

Please sign in to comment.