Skip to content
Snippets Groups Projects
Commit 6ca54a1b authored by Philippe Canal's avatar Philippe Canal
Browse files

From Elvin:

Disable the normal reading mode as a fall-back method of reading and use only the prefetching mechanism. 
For the case when a request is not satisfied from the first try, we now will continue to prefetch until 
the request is within the blocks read. 
The problem seemed to appear only in the TWebFile plug-in as it was using the same connection for sending 
requests regardless of the thread. From what I understood in xrd things are different and this problem 
didn't appear while reading using the TXNetFile plug-in.
Also change the type of the prefetching thread from a detached one to a joined one as there were some 
issues with synchronization if the main thread finished reading before the worker thread finished prefetching blocks.


git-svn-id: http://root.cern.ch/svn/root/trunk@39458 27541ba8-7e3a-0410-8455-c3a389f83636
parent 56e22860
No related branches found
No related tags found
No related merge requests found
......@@ -83,7 +83,7 @@ private:
TString fPathCache; // path to the cache directory
TStopwatch fWaitTime; // time wating to prefetch a buffer (in usec)
static void ThreadProc(void*);
static TThread::VoidRtnFunc_t ThreadProc(void*); //create a joinable worker thread
public:
TFilePrefetch(TFile*);
......
......@@ -56,6 +56,8 @@ TFilePrefetch::~TFilePrefetch()
//killing consumer thread
fSem->Post();
fNewBlockAdded->Signal();
fConsumer->Join();
fConsumer->Delete();
delete fPendingBlocks;
delete fReadBlocks;
......@@ -299,15 +301,14 @@ Int_t TFilePrefetch::ThreadStart()
{
// Used to start the consumer thread.
fConsumer= new TThread("consumerThread",
(void(*) (void *))ThreadProc,
fConsumer= new TThread((TThread::VoidRtnFunc_t) ThreadProc,
(void*) this);
fConsumer->Run();
return 1;
}
//____________________________________________________________________________________________
void TFilePrefetch::ThreadProc(void* arg)
TThread::VoidRtnFunc_t TFilePrefetch::ThreadProc(void* arg)
{
// Execution loop of the consumer thread.
......@@ -315,8 +316,11 @@ void TFilePrefetch::ThreadProc(void* arg)
while(tmp->fSem->TryWait() !=0){
tmp->ReadListOfBlocks();
if (tmp->fSem->TryWait() == 0) break;
tmp->fNewBlockAdded->Wait();
}
return (TThread::VoidRtnFunc_t) 1;
}
//########################################### CACHING PART ###############################################################
......
......@@ -471,7 +471,7 @@ Bool_t TTreeCache::FillBuffer()
}
if (fReverseRead){ //reverse reading with prefetching
if (fEntryCurrent >0 && entry >= fEntryCurrent && entry < fEntryNext){
if (fEntryCurrent >0 && entry < fEntryNext){
//we can prefetch the next buffer
entry = fEntryCurrent - tree->GetAutoFlush() * fFillTimes;
if (entry < 0)
......@@ -779,21 +779,16 @@ Int_t TTreeCache::ReadBufferPrefetch(char *buf, Long64_t pos, Int_t len){
return 1;
}
//not found in cache. Do we need to fill the cache?
Bool_t bufferFilled = FillBuffer();
if (bufferFilled) {
Int_t res = TFileCacheRead::ReadBuffer(buf,pos,len);
if (res == 1)
fNReadOk++;
else if (res == 0)
//keep on prefetching until request is satisfied
while (1){
if(TFileCacheRead::ReadBuffer(buf, pos, len))
break;
FillBuffer();
fNReadMiss++;
return res;
}
fNReadMiss++;
return 0;
fNReadOk++;
return 1;
}
//_____________________________________________________________________________
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment