Skip to content

Commit

Permalink
Add bit array for prefetch status.
Browse files Browse the repository at this point in the history
  • Loading branch information
alja authored and abh3 committed Jun 30, 2016
1 parent 676ce7b commit 8f7ca00
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/XrdFileCache/XrdFileCacheInfo.cc
Expand Up @@ -49,18 +49,23 @@ Info::~Info()
{
if (m_buff_fetched) free(m_buff_fetched);
if (m_buff_write_called) free(m_buff_write_called);
if (m_buff_prefetch) free(m_buff_prefetch);
}

//______________________________________________________________________________


void Info::ResizeBits(int s)
void Info::ResizeBits(int s, bool prefetch_stat)
{
m_sizeInBits = s;
m_buff_fetched = (unsigned char*)malloc(GetSizeInBytes());
m_buff_write_called = (unsigned char*)malloc(GetSizeInBytes());
memset(m_buff_fetched, 0, GetSizeInBytes());
memset(m_buff_write_called, 0, GetSizeInBytes());
if (prefetch_stat) {
m_buff_prefetch = (unsigned char*)malloc(GetSizeInBytes());
memset(m_buff_prefetch, 0, GetSizeInBytes());
}
}

//______________________________________________________________________________
Expand Down
35 changes: 34 additions & 1 deletion src/XrdFileCache/XrdFileCacheInfo.hh
Expand Up @@ -79,12 +79,19 @@ namespace XrdFileCache
//---------------------------------------------------------------------
void SetBitWriteCalled(int i);

//! \brief Mark block as written from prefetch
//!
//! @param i block index
//---------------------------------------------------------------------
void SetBitPrefetch(int i);


//---------------------------------------------------------------------
//! \brief Reserve buffer for fileSize/bufferSize bytes
//!
//! @param n number of file blocks
//---------------------------------------------------------------------
void ResizeBits(int n);
void ResizeBits(int n, bool prefetch_stat = false);

//---------------------------------------------------------------------
//! \brief Rea load content from cinfo file into this object
Expand Down Expand Up @@ -140,6 +147,11 @@ namespace XrdFileCache
//---------------------------------------------------------------------
bool TestBit(int i) const;

//---------------------------------------------------------------------
//! Test if block at the given index is prefetched
//---------------------------------------------------------------------
bool TestPrefetchBit(int i) const;

//---------------------------------------------------------------------
//! Get complete status
//---------------------------------------------------------------------
Expand Down Expand Up @@ -186,6 +198,7 @@ namespace XrdFileCache
int m_sizeInBits; //!< number of file blocks
unsigned char *m_buff_fetched; //!< download state vector
unsigned char *m_buff_write_called; //!< disk written state vector
unsigned char *m_buff_prefetch; //!< prefetch state vector
int m_accessCnt; //!< number of written AStat structs
bool m_complete; //!< cached
};
Expand All @@ -199,6 +212,16 @@ namespace XrdFileCache
return (m_buff_fetched[cn] & cfiBIT(off)) == cfiBIT(off);
}

// AMT could have only one function to test bit and pass an argument, but would loose clarity
inline bool Info::TestPrefetchBit(int i) const
{
int cn = i/8;
assert(cn < GetSizeInBytes());

int off = i - cn*8;
return (m_buff_prefetch[cn] & cfiBIT(off)) == cfiBIT(off);
}


inline int Info::GetNDownloadedBlocks() const
{
Expand Down Expand Up @@ -260,6 +283,16 @@ namespace XrdFileCache
m_buff_fetched[cn] |= cfiBIT(off);
}

inline void Info::SetBitPrefetch(int i)
{
int cn = i/8;
assert(cn < GetSizeInBytes());

int off = i - cn*8;
m_buff_prefetch[cn] |= cfiBIT(off);
}


inline long long Info::GetBufferSize() const
{
return m_bufferSize;
Expand Down

0 comments on commit 8f7ca00

Please sign in to comment.