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
72 using namespace edm::storage;
112 Bool_t parallelopen )
113 : TFile(path,
"NET", ftitle, compress),
126 : TFile(path,
"NET", ftitle, compress),
143 gEnv->SetValue(
"TFile.AsyncReading", 1);
149 if (fOption ==
"NEW")
152 Bool_t
create = (fOption ==
"CREATE");
153 Bool_t recreate = (fOption ==
"RECREATE");
154 Bool_t
update = (fOption ==
"UPDATE");
155 Bool_t
read = (fOption ==
"READ") || (fOption ==
"READWRAP");
156 Bool_t readwrap = (fOption ==
"READWRAP");
158 if (!create && !recreate && !update && !read) {
164 if (!gSystem->AccessPathName(path, kFileExists))
165 gSystem->Unlink(path);
173 if (update && gSystem->AccessPathName(path, kFileExists)) {
178 assert(read || update || create);
193 throw cms::Exception(
"TStorageFactoryFile::TStorageFactoryFile()") <<
"Cannot open file '" << path <<
"'";
210 fWritable = read ? kFALSE : kTRUE;
233 Error(
"ReadBuffer",
"Cannot read from a zombie file");
238 Error(
"ReadBuffer",
"Cannot read from a file that is not open");
255 if (TFileCacheRead *
c = GetCacheRead()) {
256 Long64_t here = GetRelOffset();
257 Bool_t async =
c->IsAsyncReading();
263 Int_t st = ReadBufferViaCache(async ?
nullptr : buf, len);
267 "ReadBufferViaCache failed. Asked to read nBytes: %d from offset: %lld with file size: %lld",
294 if (n < static_cast<IOSize>(len)) {
296 "read from Storage::xread returned %ld. Asked to read n bytes: %d from offset: %lld with file size: %lld",
302 return n ? kFALSE : kTRUE;
308 Error(
"ReadBufferAsync",
"Cannot read from a zombie file");
313 Error(
"ReadBufferAsync",
"Cannot read from a file that is not open");
326 if (f->
cacheHint() == StorageFactory::CACHE_HINT_APPLICATION)
347 if (f->
cacheHint() == StorageFactory::CACHE_HINT_STORAGE)
375 Int_t remaining = nbuf;
378 IOSize remaining_buffer_size = 0;
381 for (Int_t
i = 0;
i < nbuf;
i++)
382 remaining_buffer_size += len[
i];
384 char *current_buffer =
buf;
385 Long64_t *current_pos = pos;
386 Int_t *current_len = len;
390 while (remaining > 0) {
391 pack_count = repacker.
pack(
392 static_cast<long long int *>(current_pos), current_len, remaining, current_buffer, remaining_buffer_size);
399 std::vector<IOPosBuffer> &iov = repacker.
iov();
401 if (result != io_buffer_used) {
403 "ReadBuffersSync",
"Storage::readv returned different size result=%ld expected=%ld", result, io_buffer_used);
406 xstats.
tick(io_buffer_used);
407 repacker.
unpack(current_buffer);
410 remaining_buffer_size -= real_bytes_processed;
411 current_buffer += real_bytes_processed;
413 current_pos += pack_count;
414 current_len += pack_count;
415 remaining -= pack_count;
417 assert(remaining_buffer_size == 0);
424 Error(
"ReadBuffers",
"Cannot read from a zombie file");
429 Error(
"ReadBuffers",
"Cannot read from a file that is not open");
442 void *
const nobuf =
nullptr;
444 std::vector<IOPosBuffer> iov;
446 for (Int_t
i = 0;
i < nbuf; ++
i) {
447 iov.emplace_back(pos[
i], nobuf, len[i]);
456 success =
storage_->prefetch(iov.data(), nbuf);
461 if (TFile::ReadBuffers(buf, pos, len, nbuf)) {
462 Error(
"ReadBuffers",
"call to TFile::ReadBuffers failed after prefetch already failed.");
472 Error(
"WriteBuffer",
"Cannot write to a zombie file");
477 Error(
"WriteBuffer",
"Cannot write to a file that is not open");
482 Error(
"WriteBuffer",
"File is not writable");
491 switch ((st = WriteBufferViaCache(buf, len))) {
501 return n > 0 ? kFALSE : kTRUE;
511 Error(
"WriteBuffer",
"Error writing to cache");
534 if (flags & O_WRONLY)
536 else if (flags & O_RDWR)
540 if (flags & O_APPEND)
552 throw cms::Exception(
"TStorageFactoryFile::SysOpen()") <<
"Cannot open file '" << pathname <<
"'";
573 Storage::Relative rel = (whence == SEEK_SET ? Storage::SET : whence == SEEK_CUR ? Storage::CURRENT : Storage::END);
575 offset =
storage_->position(offset, rel);
Code categoryCode() const
edm::ErrorSummaryEntry Error
TStorageFactoryFile(void)
static StorageAccount::Counter * s_statsWrite
static StorageAccount::Counter * s_statsStat
const edm::EventSetup & c
static StorageClassToken tokenForStorageClassName(std::string const &iName)
void setSize(const std::string &urlOrLfn, size_t size)
Long64_t SysSeek(Int_t fd, Long64_t offset, Int_t whence) override
static StorageAccount::Counter * s_statsXWrite
static StorageAccount::Counter * s_statsClose
Int_t SysClose(Int_t fd) override
static Counter & counter(StorageClassToken token, Operation operation)
Bool_t ReadBufferAsync(Long64_t off, Int_t len) override
Bool_t ReadBuffer(char *buf, Int_t len) override
CacheHint cacheHint(void) const
edm::propagate_const< std::unique_ptr< edm::storage::Storage > > storage_
IOSize realBytesProcessed() const
static StorageAccount::Counter * s_statsARead
static StorageAccount::Counter & storageCounter(StorageAccount::Counter *&c, StorageAccount::Operation operation)
constexpr int PREFETCH_PROBE_LENGTH
static StorageAccount::Counter * s_statsCtor
ClassImp(AliDaqEventHeader)
XrdSiteStatisticsInformation * statsService
int pack(long long int *pos, int *len, int nbuf, char *buf, IOSize buffer_size)
void tick(uint64_t amount=0, int64_t tick=0) const
static StorageAccount::Counter * s_statsRead
static StorageAccount::Counter * s_statsXRead
static StorageAccount::Counter * s_statsFlush
Int_t SysOpen(const char *pathname, Int_t flags, UInt_t mode) override
static StorageAccount::Counter * s_statsCWrite
IOSize bufferUsed() const
std::vector< IOPosBuffer > & iov()
void setException(std::exception_ptr e)
void ResetErrno(void) const override
~TStorageFactoryFile(void) override
static StorageAccount::Counter * s_statsSeek
Int_t SysSync(Int_t fd) override
static StorageAccount::Counter * s_statsOpen
Bool_t WriteBuffer(const char *buf, Int_t len) override
std::unique_ptr< GeometricDet > construct(DDCompactView const &cpv, std::vector< int > const &detidShifts)
Bool_t ReadBuffers(char *buf, Long64_t *pos, Int_t *len, Int_t nbuf) override
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.
tuple dump
OutputFilePath = cms.string('/tmp/zhokin/'), OutputFileExt = cms.string(''),.
static StorageAccount::Counter * s_statsCPrefetch
Int_t SysStat(Int_t fd, Long_t *id, Long64_t *size, Long_t *flags, Long_t *modtime) override
static StorageAccount::Counter * s_statsCRead