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);
307 return n ? kFALSE : kTRUE;
316 Error(
"ReadBufferAsync",
"Cannot read from a zombie file");
322 Error(
"ReadBufferAsync",
"Cannot read from a file that is not open");
387 Int_t remaining = nbuf;
390 IOSize remaining_buffer_size=0;
393 for (Int_t
i=0;
i<nbuf;
i++) remaining_buffer_size+=len[
i];
395 char *current_buffer = buf;
396 Long64_t *current_pos = pos;
397 Int_t *current_len = len;
401 while (remaining > 0) {
403 pack_count = repacker.
pack(static_cast<long long int *>(current_pos), current_len, remaining, current_buffer, remaining_buffer_size);
410 std::vector<IOPosBuffer> &
iov = repacker.
iov();
412 if (result != io_buffer_used) {
415 xstats.
tick(io_buffer_used);
416 repacker.
unpack(current_buffer);
419 remaining_buffer_size -= real_bytes_processed;
420 current_buffer += real_bytes_processed;
422 current_pos += pack_count;
423 current_len += pack_count;
424 remaining -= pack_count;
427 assert(remaining_buffer_size == 0);
437 Error(
"ReadBuffers",
"Cannot read from a zombie file");
443 Error(
"ReadBuffers",
"Cannot read from a file that is not open");
457 void*
const nobuf = 0;
459 std::vector<IOPosBuffer>
iov;
461 for (Int_t
i = 0;
i < nbuf; ++
i)
472 success =
storage_->prefetch(&iov[0], nbuf);
476 return success ? kFALSE : TFile::ReadBuffers(buf, pos, len, nbuf);
485 Error(
"WriteBuffer",
"Cannot write to a zombie file");
491 Error(
"WriteBuffer",
"Cannot write to a file that is not open");
497 Error(
"WriteBuffer",
"File is not writable");
506 switch ((st = WriteBufferViaCache(buf, len)))
517 return n > 0 ? kFALSE : kTRUE;
527 Error(
"WriteBuffer",
"Error writing to cache");
566 <<
"Cannot open file '" << pathname <<
"'";
596 offset =
storage_->position(offset, rel);
612 Long_t *
flags, Long_t *modtime)
627 TSystem::ResetErrno();
Code categoryCode() const
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)
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)
IOSize realBytesProcessed() const
static StorageAccount::Counter * s_statsARead
static StorageClassToken tokenForStorageClassName(std::string const &iName)
static StorageAccount::Counter & storageCounter(StorageAccount::Counter *&c, StorageAccount::Operation operation)
virtual Bool_t ReadBufferAsync(Long64_t off, Int_t len)
unsigned int(* Counter)(align::ID, const TrackerTopology *)
static StorageAccount::Counter * s_statsCtor
virtual Bool_t ReadBuffer(char *buf, Int_t len)
XrdSiteStatisticsInformation * statsService
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
static StorageAccount::Counter * s_statsOpen
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="")
tuple size
Write out results.
static StorageAccount::Counter * s_statsCPrefetch
static StorageAccount::Counter * s_statsCRead