From fd98b55fd261ff1af75bce359b227c86eed396df Mon Sep 17 00:00:00 2001 From: Alja Mrak-Tadel Date: Fri, 17 Jun 2016 14:42:19 -0700 Subject: [PATCH] Store access statistics in bytes instead of number of blocks --- src/XrdFileCache/XrdFileCacheFile.cc | 9 +++------ src/XrdFileCache/XrdFileCacheVRead.cc | 5 +++++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/XrdFileCache/XrdFileCacheFile.cc b/src/XrdFileCache/XrdFileCacheFile.cc index bfc60bbe88a..f57ecd986a6 100644 --- a/src/XrdFileCache/XrdFileCacheFile.cc +++ b/src/XrdFileCache/XrdFileCacheFile.cc @@ -421,10 +421,10 @@ int File::ReadBlocksFromDisk(std::list& blocks, total += rs; - CheckPrefetchStatDisk(*ii); } + m_stats.m_BytesDisk += total; return total; } @@ -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 @@ -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++; } } @@ -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. @@ -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 { diff --git a/src/XrdFileCache/XrdFileCacheVRead.cc b/src/XrdFileCache/XrdFileCacheVRead.cc index c903dc3bd0d..f0ac1d1936a 100644 --- a/src/XrdFileCache/XrdFileCacheVRead.cc +++ b/src/XrdFileCache/XrdFileCacheVRead.cc @@ -125,7 +125,10 @@ int File::ReadV (const XrdOucIOVec *readV, int n) if (direct_handler->m_errno == 0) { for (std::vector::iterator i = chunkVec.begin(); i != chunkVec.end(); ++i) + { bytesRead += i->size; + m_stats.m_BytesMissed += i->size; + } } else { @@ -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 @@ -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 {