9 #include "TFileCacheRead.h"
21 #include "TTreeCache.h"
24 class TTreeCacheDebug :
public TTreeCache {
26 void dump(
const char *
label,
const char *trailer)
28 Long64_t entry = fOwner->GetReadEntry();
30 << label <<
": " << entry <<
" "
31 <<
"{ fEntryMin=" << fEntryMin
32 <<
", fEntryMax=" << fEntryMax
33 <<
", fEntryNext=" << fEntryNext
34 <<
", fZipBytes=" << fZipBytes
35 <<
", fNbranches=" << fNbranches
36 <<
", fNReadOk=" << fNReadOk
37 <<
", fNReadMiss=" << fNReadMiss
38 <<
", fNReadPref=" << fNReadPref
39 <<
", fBranches=" << fBranches
40 <<
", fBrNames=" << fBrNames
41 <<
", fOwner=" << fOwner
42 <<
", fTree=" << fTree
43 <<
", fIsLearning=" << fIsLearning
44 <<
", fIsManual=" << fIsManual
45 <<
"; fBufferSizeMin=" << fBufferSizeMin
46 <<
", fBufferSize=" << fBufferSize
47 <<
", fBufferLen=" << fBufferLen
48 <<
", fBytesToPrefetch=" << fBytesToPrefetch
49 <<
", fFirstIndexToPrefetch=" << fFirstIndexToPrefetch
50 <<
", fAsyncReading=" << fAsyncReading
51 <<
", fNseek=" << fNseek
52 <<
", fNtot=" << fNtot
54 <<
", fSeekSize=" << fSeekSize
55 <<
", fSeek=" << fSeek
56 <<
", fSeekIndex=" << fSeekIndex
57 <<
", fSeekSort=" << fSeekSort
59 <<
", fSeekLen=" << fSeekLen
60 <<
", fSeekSortLen=" << fSeekSortLen
61 <<
", fSeekPos=" << fSeekPos
63 <<
", fFile=" << fFile
64 <<
", fBuffer=" << (
void *) fBuffer
65 <<
", fIsSorted=" << fIsSorted
110 Bool_t parallelopen )
111 : TFile(path,
"NET", ftitle, compress),
121 : TFile(path,
"NET", ftitle, compress),
138 gEnv->SetValue(
"TFile.AsyncReading", 1);
144 if (fOption ==
"NEW")
147 Bool_t
create = (fOption ==
"CREATE");
148 Bool_t recreate = (fOption ==
"RECREATE");
149 Bool_t
update = (fOption ==
"UPDATE");
150 Bool_t
read = (fOption ==
"READ");
152 if (!create && !recreate && !update && !read)
160 if (!gSystem->AccessPathName(path, kFileExists))
161 gSystem->Unlink(path);
169 if (update && gSystem->AccessPathName(path, kFileExists))
175 assert(read || update || create);
187 throw cms::Exception(
"TStorageFactoryFile::TStorageFactoryFile()")
188 <<
"Cannot open file '" << path <<
"'";
205 fWritable = read ? kFALSE : kTRUE;
237 Error(
"ReadBuffer",
"Cannot read from a zombie file");
243 Error(
"ReadBuffer",
"Cannot read from a file that is not open");
260 if (TFileCacheRead *
c = GetCacheRead())
262 Long64_t here = GetRelOffset();
263 Bool_t async =
c->IsAsyncReading();
269 Int_t st = ReadBufferViaCache(async ? 0 : buf, len);
295 return n ? kFALSE : kTRUE;
304 Error(
"ReadBufferAsync",
"Cannot read from a zombie file");
310 Error(
"ReadBufferAsync",
"Cannot read from a file that is not open");
375 Int_t remaining = nbuf;
378 IOSize remaining_buffer_size=0;
381 for (Int_t
i=0;
i<nbuf;
i++) remaining_buffer_size+=len[
i];
383 char *current_buffer = buf;
384 Long64_t *current_pos = pos;
385 Int_t *current_len = len;
389 while (remaining > 0) {
391 pack_count = repacker.
pack(static_cast<long long int *>(current_pos), current_len, remaining, current_buffer, remaining_buffer_size);
398 std::vector<IOPosBuffer> &
iov = repacker.
iov();
400 if (result != io_buffer_used) {
403 xstats.
tick(io_buffer_used);
404 repacker.
unpack(current_buffer);
407 remaining_buffer_size -= real_bytes_processed;
408 current_buffer += real_bytes_processed;
410 current_pos += pack_count;
411 current_len += pack_count;
412 remaining -= pack_count;
415 assert(remaining_buffer_size == 0);
425 Error(
"ReadBuffers",
"Cannot read from a zombie file");
431 Error(
"ReadBuffers",
"Cannot read from a file that is not open");
445 void*
const nobuf = 0;
447 std::vector<IOPosBuffer>
iov;
449 for (Int_t
i = 0;
i < nbuf; ++
i)
464 return success ? kFALSE : TFile::ReadBuffers(buf, pos, len, nbuf);
473 Error(
"WriteBuffer",
"Cannot write to a zombie file");
479 Error(
"WriteBuffer",
"Cannot write to a file that is not open");
485 Error(
"WriteBuffer",
"File is not writable");
494 switch ((st = WriteBufferViaCache(buf, len)))
505 return n > 0 ? kFALSE : kTRUE;
515 Error(
"WriteBuffer",
"Error writing to cache");
556 <<
"Cannot open file '" << pathname <<
"'";
603 Long_t *
flags, Long_t *modtime)
618 TSystem::ResetErrno();
Code categoryCode() const
TStorageFactoryFile(void)
IOSize xwrite(const void *from, IOSize n)
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)
void tick(double amount=0., int64_t tick=0) const
virtual IOSize readv(IOPosBuffer *into, IOSize buffers)
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)
static StorageFactory * get(void)
static StorageAccount::Counter & storageCounter(StorageAccount::Counter *&c, const char *label)
IOSize realBytesProcessed() const
static StorageAccount::Counter * s_statsARead
tuple path
else: Piece not in the list, fine.
virtual Bool_t ReadBufferAsync(Long64_t off, Int_t len)
unsigned int(* Counter)(align::ID, const TrackerTopology *)
virtual IOOffset position(void) const
static StorageAccount::Counter * s_statsCtor
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)
unsigned int offset(bool)
static StorageAccount::Counter * s_statsRead
static StorageAccount::Counter * s_statsXRead
static StorageAccount::Counter * s_statsFlush
virtual bool prefetch(const IOPosBuffer *what, IOSize n)
static StorageAccount::Counter * s_statsCWrite
static Counter & counter(const std::string &storageClass, const std::string &operation)
IOSize bufferUsed() const
virtual IOOffset size(void) const
~TStorageFactoryFile(void)
std::vector< IOPosBuffer > & iov()
void ResetErrno(void) 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