10 #include "TFileCacheRead.h" 22 #include "TTreeCache.h" 25 class TTreeCacheDebug :
public TTreeCache {
27 void dump(
const char *
label,
const char *trailer)
29 Long64_t
entry = fOwner->GetReadEntry();
31 << label <<
": " << entry <<
" " 32 <<
"{ fEntryMin=" << fEntryMin
33 <<
", fEntryMax=" << fEntryMax
34 <<
", fEntryNext=" << fEntryNext
35 <<
", fZipBytes=" << fZipBytes
36 <<
", fNbranches=" << fNbranches
37 <<
", fNReadOk=" << fNReadOk
38 <<
", fNReadMiss=" << fNReadMiss
39 <<
", fNReadPref=" << fNReadPref
40 <<
", fBranches=" << fBranches
41 <<
", fBrNames=" << fBrNames
42 <<
", fOwner=" << fOwner
43 <<
", fTree=" << fTree
44 <<
", fIsLearning=" << fIsLearning
45 <<
", fIsManual=" << fIsManual
46 <<
"; fBufferSizeMin=" << fBufferSizeMin
47 <<
", fBufferSize=" << fBufferSize
48 <<
", fBufferLen=" << fBufferLen
49 <<
", fBytesToPrefetch=" << fBytesToPrefetch
50 <<
", fFirstIndexToPrefetch=" << fFirstIndexToPrefetch
51 <<
", fAsyncReading=" << fAsyncReading
52 <<
", fNseek=" << fNseek
53 <<
", fNtot=" << fNtot
55 <<
", fSeekSize=" << fSeekSize
56 <<
", fSeek=" << fSeek
57 <<
", fSeekIndex=" << fSeekIndex
58 <<
", fSeekSort=" << fSeekSort
60 <<
", fSeekLen=" << fSeekLen
61 <<
", fSeekSortLen=" << fSeekSortLen
62 <<
", fSeekPos=" << fSeekPos
64 <<
", fFile=" << fFile
65 <<
", fBuffer=" << (
void *) fBuffer
66 <<
", fIsSorted=" << fIsSorted
113 Bool_t parallelopen )
114 : TFile(path,
"NET", ftitle, compress),
128 : TFile(path,
"NET", ftitle, compress),
149 gEnv->SetValue(
"TFile.AsyncReading", 1);
155 if (fOption ==
"NEW")
158 Bool_t
create = (fOption ==
"CREATE");
159 Bool_t recreate = (fOption ==
"RECREATE");
160 Bool_t
update = (fOption ==
"UPDATE");
161 Bool_t read = (fOption ==
"READ") || (fOption ==
"READWRAP");
162 Bool_t readwrap = (fOption ==
"READWRAP");
164 if (!create && !recreate && !update && !read)
172 if (!gSystem->AccessPathName(path, kFileExists))
173 gSystem->Unlink(path);
181 if (update && gSystem->AccessPathName(path, kFileExists))
187 assert(read || update || create);
200 throw cms::Exception(
"TStorageFactoryFile::TStorageFactoryFile()")
201 <<
"Cannot open file '" << path <<
"'";
218 fWritable = read ? kFALSE : kTRUE;
249 Error(
"ReadBuffer",
"Cannot read from a zombie file");
255 Error(
"ReadBuffer",
"Cannot read from a file that is not open");
272 if (TFileCacheRead *
c = GetCacheRead())
274 Long64_t here = GetRelOffset();
275 Bool_t async =
c->IsAsyncReading();
281 Int_t st = ReadBufferViaCache(async ? 0 : buf, len);
284 Error(
"ReadBuffer",
"ReadBufferViaCache failed. Asked to read nBytes: %d from offset: %lld with file size: %lld",len, here, GetSize());
308 if(n < static_cast<IOSize>(len)) {
309 Error(
"ReadBuffer",
"read from Storage::xread returned %ld. Asked to read n bytes: %d from offset: %lld with file size: %lld",n, len, GetRelOffset(), GetSize());
311 return n ? kFALSE : kTRUE;
320 Error(
"ReadBufferAsync",
"Cannot read from a zombie file");
326 Error(
"ReadBufferAsync",
"Cannot read from a file that is not open");
391 Int_t remaining = nbuf;
394 IOSize remaining_buffer_size=0;
397 for (Int_t
i=0;
i<nbuf;
i++) remaining_buffer_size+=len[
i];
399 char *current_buffer = buf;
400 Long64_t *current_pos = pos;
401 Int_t *current_len = len;
405 while (remaining > 0) {
407 pack_count = repacker.
pack(static_cast<long long int *>(current_pos), current_len, remaining, current_buffer, remaining_buffer_size);
414 std::vector<IOPosBuffer> &iov = repacker.
iov();
416 if (result != io_buffer_used) {
417 Error(
"ReadBuffersSync",
"Storage::readv returned different size result=%ld expected=%ld",result,io_buffer_used);
420 xstats.
tick(io_buffer_used);
421 repacker.
unpack(current_buffer);
424 remaining_buffer_size -= real_bytes_processed;
425 current_buffer += real_bytes_processed;
427 current_pos += pack_count;
428 current_len += pack_count;
429 remaining -= pack_count;
432 assert(remaining_buffer_size == 0);
442 Error(
"ReadBuffers",
"Cannot read from a zombie file");
448 Error(
"ReadBuffers",
"Cannot read from a file that is not open");
462 void*
const nobuf = 0;
464 std::vector<IOPosBuffer> iov;
466 for (Int_t
i = 0;
i < nbuf; ++
i)
477 success =
storage_->prefetch(&iov[0], nbuf);
482 if(TFile::ReadBuffers(buf, pos, len, nbuf)) {
483 Error(
"ReadBuffers",
"call to TFile::ReadBuffers failed after prefetch already failed.");
496 Error(
"WriteBuffer",
"Cannot write to a zombie file");
502 Error(
"WriteBuffer",
"Cannot write to a file that is not open");
508 Error(
"WriteBuffer",
"File is not writable");
517 switch ((st = WriteBufferViaCache(buf, len)))
528 return n > 0 ? kFALSE : kTRUE;
538 Error(
"WriteBuffer",
"Error writing to cache");
577 <<
"Cannot open file '" << pathname <<
"'";
607 offset =
storage_->position(offset, rel);
623 Long_t *
flags, Long_t *modtime)
638 TSystem::ResetErrno();
Code categoryCode() const
edm::ErrorSummaryEntry Error
TStorageFactoryFile(void)
CacheHint cacheHint(void) const
static StorageAccount::Counter * s_statsWrite
static StorageAccount::Counter * s_statsStat
#define PREFETCH_PROBE_LENGTH
virtual Long64_t SysSeek(Int_t fd, Long64_t offset, Int_t whence)
def create(alignables, pedeDump, additionalData, outputFile, config)
virtual Int_t SysOpen(const char *pathname, Int_t flags, UInt_t mode)
static StorageAccount::Counter * s_statsXWrite
static StorageAccount::Counter * s_statsClose
std::vector< Variable::Flags > flags
virtual Bool_t ReadBuffers(char *buf, Long64_t *pos, Int_t *len, Int_t nbuf)
edm::propagate_const< std::unique_ptr< Storage > > storage_
static const StorageFactory * get(void)
std::function< unsigned int(align::ID)> Counter
IOSize realBytesProcessed() const
ClassImp(AliDaqEventHeader) ClassImp(AliDaqPosition2D) ClassImp(AliDaqPositionCOPS) ClassImp(AliDaqTilt) ClassImp(AliDaqDistance) ClassImp(AliDaqTemperature) ClassImp(CocoaDaqRootEvent) CocoaDaqRootEvent
static StorageAccount::Counter * s_statsARead
static StorageClassToken tokenForStorageClassName(std::string const &iName)
static ClassImp(TStorageFactoryFile) static StorageAccount StorageAccount::Counter * s_statsOpen
static StorageAccount::Counter & storageCounter(StorageAccount::Counter *&c, StorageAccount::Operation operation)
virtual Bool_t ReadBufferAsync(Long64_t off, Int_t len)
virtual Bool_t ReadBuffer(char *buf, Int_t len)
virtual Bool_t WriteBuffer(const char *buf, Int_t len)
int pack(long long int *pos, int *len, int nbuf, char *buf, IOSize buffer_size)
static StorageAccount::Counter * s_statsRead
static StorageAccount::Counter * s_statsXRead
static StorageAccount::Counter * s_statsFlush
static Counter & counter(StorageClassToken token, Operation operation)
static StorageAccount::Counter * s_statsCWrite
IOSize bufferUsed() const
~TStorageFactoryFile(void)
std::vector< IOPosBuffer > & iov()
void setException(std::exception_ptr e)
void ResetErrno(void) const
void tick(uint64_t amount=0, int64_t tick=0) const
void setSize(size_t size)
virtual Int_t SysStat(Int_t fd, Long_t *id, Long64_t *size, Long_t *flags, Long_t *modtime)
virtual Int_t SysClose(Int_t fd)
static StorageAccount::Counter * s_statsSeek
virtual Int_t SysSync(Int_t fd)
Bool_t ReadBuffersSync(char *buf, Long64_t *pos, Int_t *len, Int_t nbuf)
void Initialize(const char *name, Option_t *option="")
static StorageAccount::Counter * s_statsCPrefetch
static StorageAccount::Counter * s_statsCRead