356 if (!
b ||
fTree->GetTree() !=
b->GetTree())
return -1;
378 if (!
b ||
fTree->GetTree() !=
b->GetTree())
return -1;
383 if (
fBranches->UncheckedAt(i) ==
b) {isNew =
false;
break;}
388 const char *bname =
b->GetName();
396 const char *mothername =
b->GetMother()->GetName();
397 if (
b !=
b->GetMother() && mothername[strlen(mothername)-1] !=
'.') {
400 if (bem->GetType() < 3) {
404 if (strncmp(bname,build.
Data(),build.
Length()) != 0) {
406 bname = build.
Data();
413 if (
gDebug > 0) printf(
"Entry: %lld, registering branch: %s\n",
b->GetTree()->GetReadEntry(),
b->GetName());
421 for (
Int_t j = 0; j < nb; j++) {
423 if (!branch)
continue;
448 TLeaf *leaf, *leafcount;
451 Int_t nleaves = (
fTree->GetListOfLeaves())->GetEntriesFast();
459 if (!strcmp(bname,
"*")) all =
true;
460 for (i=0;i<nleaves;i++) {
461 leaf = (
TLeaf*)(
fTree->GetListOfLeaves())->UncheckedAt(i);
467 if (strcmp(bname,branch->
GetName())
476 if (leafcount && !all) {
483 if (nb==0 && strchr(bname,
'*')==
nullptr) {
484 branch =
fTree->GetBranch(bname);
495 if (
fTree->GetListOfFriends()) {
501 if (t==
nullptr)
continue;
504 char *subbranch = (
char*)strstr(bname,fe->
GetName());
505 if (subbranch!=bname) subbranch =
nullptr;
507 subbranch += strlen(fe->
GetName());
508 if ( *subbranch !=
'.' ) subbranch =
nullptr;
520 if (!nb && !foundInFriend) {
521 if (
gDebug > 0) printf(
"AddBranch: unknown branch -> %s \n", bname);
522 Error(
"AddBranch",
"unknown branch -> %s", bname);
547 if (!
b ||
fTree->GetTree() !=
b->GetTree())
return -1;
552 if (
gDebug > 0) printf(
"Entry: %lld, un-registering branch: %s\n",
b->GetTree()->GetReadEntry(),
b->GetName());
561 for (
Int_t j = 0; j < nb; j++) {
563 if (!branch)
continue;
588 TLeaf *leaf, *leafcount;
591 Int_t nleaves = (
fTree->GetListOfLeaves())->GetEntriesFast();
599 if (!strcmp(bname,
"*")) all =
true;
600 for (i=0;i<nleaves;i++) {
601 leaf = (
TLeaf*)(
fTree->GetListOfLeaves())->UncheckedAt(i);
607 if (strcmp(bname,branch->
GetName())
616 if (leafcount && !all) {
623 if (nb==0 && strchr(bname,
'*')==
nullptr) {
624 branch =
fTree->GetBranch(bname);
635 if (
fTree->GetListOfFriends()) {
641 if (t==
nullptr)
continue;
644 char *subbranch = (
char*)strstr(bname,fe->
GetName());
645 if (subbranch!=bname) subbranch =
nullptr;
647 subbranch += strlen(fe->
GetName());
648 if ( *subbranch !=
'.' ) subbranch =
nullptr;
660 if (!nb && !foundInFriend) {
661 if (
gDebug > 0) printf(
"DropBranch: unknown branch -> %s \n", bname);
662 Error(
"DropBranch",
"unknown branch -> %s", bname);
729 Int_t *lbaskets =
b.GetBasketBytes();
736 Int_t blistsize =
b.GetWriteBasket();
745 if (basketOffset < 0) {
751 if ((basketOffset < blistsize) &&
b.GetListOfBaskets()->UncheckedAt(basketOffset)) {
757 Long64_t pos =
b.GetBasketSeek(basketOffset);
758 Int_t len = lbaskets[basketOffset];
795 int count = all ? (
fTree->GetListOfLeaves())->GetEntriesFast() :
fMissCache->fBranches.size();
798 bool found_request =
false;
799 TBranch *resultBranch =
nullptr;
802 std::vector<std::pair<size_t, Int_t>> basketsInfo;
806 for (
int i = 0; i < count; i++) {
808 all ?
static_cast<TBranch *
>(
static_cast<TLeaf *
>((
fTree->GetListOfLeaves())->UncheckedAt(i))->GetBranch())
811 if (iopos.
fLen == 0) {
814 if (iopos.
fPos == pos && iopos.
fLen == len) {
815 found_request =
true;
823 Int_t blistsize =
b->GetWriteBasket();
824 Int_t basketNumber = -1;
825 for (
Int_t bn = 0; bn < blistsize; ++bn) {
826 if (iopos.
fPos ==
b->GetBasketSeek(bn)) {
831 if (basketNumber >= 0)
832 basketsInfo.emplace_back((
size_t)i, basketNumber);
841 for (
auto &info : basketsInfo) {
842 perfStats->SetLoadedMiss(info.first, info.second);
865 bool firstMiss =
false;
893 std::vector<Long64_t> positions;
894 positions.reserve(
fMissCache->fEntries.size());
895 std::vector<Int_t> lengths;
899 positions.push_back(mcentry.fIO.fPos);
900 lengths.push_back(mcentry.fIO.fLen);
901 mcentry.fIndex = cumulative;
902 cumulative += mcentry.fIO.fLen;
934 auto iter = std::lower_bound(
fMissCache->fEntries.begin(),
fMissCache->fEntries.end(), mcentry);
937 if (len > iter->fIO.fLen) {
941 auto offset = iter->fIndex;
942 memcpy(buf, &(
fMissCache->fData[offset]), len);
962 auto offset = iter->fIndex;
964 memcpy(buf, &(
fMissCache->fData[offset]), len);
985 Range() : fMin(-1), fMax(-1) {}
989 if (fMin == -1 || min < fMin)
995 if (fMax == -1 || fMax < max)
999 bool Contains(
Long64_t entry) {
return (fMin <= entry && entry <= fMax); }
1002 std::vector<Range> fRanges;
1003 std::map<Long64_t,size_t> fMinimums;
1004 std::map<Long64_t,size_t> fMaximums;
1006 BasketRanges(
size_t nBranches) { fRanges.resize(nBranches); }
1010 Range &range = fRanges.at(branchNumber);
1013 range.UpdateMin(min);
1014 range.UpdateMax(max);
1016 if (old.fMax != range.fMax) {
1017 if (old.fMax != -1) {
1018 auto maxIter = fMaximums.find(old.fMax);
1019 if (maxIter != fMaximums.end()) {
1020 if (maxIter->second == 1) {
1021 fMaximums.erase(maxIter);
1023 --(maxIter->second);
1031 void Update(
size_t branchNumber,
size_t basketNumber,
Long64_t *entries,
size_t nb,
size_t max)
1033 Update(branchNumber, entries[basketNumber],
1034 (basketNumber < (nb - 1)) ? (entries[basketNumber + 1] - 1) : max - 1);
1038 bool CheckAllIncludeRange()
1041 for (
const auto &
r : fRanges) {
1042 if (result.fMin == -1 || result.fMin <
r.fMin) {
1044 result.fMin =
r.fMin;
1046 if (result.fMax == -1 ||
r.fMax < result.fMax) {
1048 result.fMax =
r.fMax;
1055 Range allIncludedRange(AllIncludedRange());
1057 return (result.fMin == allIncludedRange.fMin && result.fMax == allIncludedRange.fMax);
1067 Range AllIncludedRange()
1070 if (!fMinimums.empty())
1071 result.fMin = fMinimums.rbegin()->first;
1072 if (!fMaximums.empty())
1073 result.fMax = fMaximums.begin()->first;
1078 UInt_t BranchesRegistered()
1081 for (
const auto &
r : fRanges) {
1082 if (
r.fMin != -1 &&
r.fMax != -1)
1092 for (
const auto &
r : fRanges) {
1093 if (
r.fMin != -1 &&
r.fMax != -1)
1094 if (
r.fMin <= entry && entry <=
r.fMax)
1102 for (
size_t i = 0; i < fRanges.size(); ++i) {
1103 if (fRanges[i].fMin != -1 || fRanges[i].fMax != -1)
1104 Printf(
"Range #%zu : %lld to %lld", i, fRanges[i].fMin, fRanges[i].fMax);
1163 if (entry < 0) entry = 0;
1169 if (entry < 0)
return false;
1175 if (entry < 0 && fEntryNext > 0) {
1195 static constexpr bool showMore =
false;
1197 static const auto PrintAllCacheInfo = [](
TObjArray *branches) {
1198 for (
Int_t i = 0; i < branches->GetEntries(); i++) {
1200 b->PrintCacheInfo();
1204 if (showMore ||
gDebug > 6)
1205 Info(
"FillBuffer",
"***** Called for entry %lld", entry);
1210 bool allUsed =
true;
1213 if (!
b->fCacheInfo.AllUsed()) {
1220 if (showMore ||
gDebug > 5)
1221 Info(
"FillBuffer",
"All baskets used already, so refresh the cache early at entry %lld", entry);
1237 bool resetBranchInfo =
false;
1240 resetBranchInfo =
true;
1241 if (showMore ||
gDebug > 6)
1242 Info(
"FillBuffer",
"*** Will reset the branch information about baskets");
1243 }
else if (showMore ||
gDebug > 6) {
1244 Info(
"FillBuffer",
"*** Info we have on the set of baskets");
1251 auto entryCurrent = clusterIter();
1267 if (showMore ||
gDebug > 6)
1281 if (resetBranchInfo) {
1285 Error(
"FillBuffer",
"Inconsistency: fCurrentClusterStart=%lld fEntryCurrent=%lld fNextClusterStart=%lld "
1286 "but fEntryCurrent should not be in between the two",
1304 Int_t t = chain->GetTreeNumber();
1305 chainOffset = chain->GetTreeOffset()[t];
1310 Int_t ntotCurrentBuf = 0;
1314 ntotCurrentBuf =
fNtot;
1323 ntotCurrentBuf =
fNtot;
1330 Int_t clusterIterations = 0;
1334 Int_t nReadPrefRequest = 0;
1337 struct collectionInfo {
1338 Int_t fClusterStart{-1};
1340 bool fLoadedOnce{
false};
1342 void Rewind() { fCurrent = (fClusterStart >= 0) ? fClusterStart : 0; }
1344 std::vector<collectionInfo> cursor(
fNbranches);
1352 prevNtot = ntotCurrentBuf;
1355 bool reachedEnd =
false;
1356 bool skippedFirst =
false;
1357 bool oncePerBranch =
false;
1358 Int_t nDistinctLoad = 0;
1359 bool progress =
true;
1370 auto CollectBaskets = [
this, elist, chainOffset, entry, clusterIterations, resetBranchInfo, perfStats,
1371 &cursor, &lowestMaxEntry, &maxReadEntry, &minEntry,
1372 &reachedEnd, &skippedFirst, &oncePerBranch, &nDistinctLoad, &progress,
1373 &ranges, &memRanges, &reqRanges,
1374 &ntotCurrentBuf, &nReadPrefRequest](EPass pass, ENarrow narrow,
Long64_t maxCollectEntry) {
1378 Int_t nReachedEnd = 0;
1380 auto oldnReadPrefRequest = nReadPrefRequest;
1381 std::vector<Int_t> potentialVetoes;
1383 if (showMore ||
gDebug > 7)
1384 Info(
"CollectBaskets",
"Called with pass=%d narrow=%d maxCollectEntry=%lld", pass, narrow, maxCollectEntry);
1386 bool filled =
false;
1391 if (
b->GetDirectory()->GetFile() !=
fFile)
1393 potentialVetoes.clear();
1394 if (pass == kStart && !cursor[i].fLoadedOnce && resetBranchInfo) {
1398 b->fCacheInfo.GetUnused(potentialVetoes);
1399 if (showMore ||
gDebug > 7) {
1401 for(
auto v : potentialVetoes) {
1405 if (!potentialVetoes.empty())
1406 Info(
"FillBuffer",
"*** Potential Vetos for branch #%d: %s", i, vetolist.
Data());
1408 b->fCacheInfo.Reset();
1410 Int_t nb =
b->GetMaxBaskets();
1411 Int_t *lbaskets =
b->GetBasketBytes();
1412 Long64_t *entries =
b->GetBasketEntry();
1413 if (!lbaskets || !entries)
1417 Int_t blistsize =
b->GetListOfBaskets()->GetSize();
1419 auto maxOfBasket = [
this, nb, entries](
int j) {
1420 return ((j < (nb - 1)) ? (entries[j + 1] - 1) :
fEntryMax - 1);
1423 if (pass == kRewind)
1425 else if (cursor[i].fCurrent == -1) {
1427 cursor[i].fCurrent = (
start < 0) ? 0 :
start;
1429 for (
auto &j = cursor[i].fCurrent; j < nb; j++) {
1432 if (j < blistsize && b->GetListOfBaskets()->UncheckedAt(j)) {
1434 if (showMore ||
gDebug > 6) {
1435 ranges.Update(i, entries[j], maxOfBasket(j));
1436 memRanges.Update(i, entries[j], maxOfBasket(j));
1438 if (entries[j] <= entry && entry <= maxOfBasket(j)) {
1439 b->fCacheInfo.SetIsInCache(j);
1440 b->fCacheInfo.SetUsed(j);
1454 if (entries[j] >= maxCollectEntry) {
1460 Int_t len = lbaskets[j];
1461 if (pos <= 0 || len <= 0)
1465 if ((showMore ||
gDebug > 7) &&
1466 (!(entries[j] < minEntry && (j < nb - 1 && entries[j + 1] <= minEntry))))
1467 Info(
"FillBuffer",
"Skipping branch %s basket %d is too large for the cache: %d > %d",
1472 if (nReadPrefRequest && entries[j] > (reqRanges.AllIncludedRange().fMax + 1)) {
1482 if (showMore ||
gDebug > 8)
1483 Info(
"FillBuffer",
"Skipping for now due to gap %d/%d with %lld > %lld", i, j, entries[j],
1484 (reqRanges.AllIncludedRange().fMax + 1));
1488 if (entries[j] < minEntry && (j<nb-1 && entries[j+1] <= minEntry))
1492 if (cursor[i].fClusterStart == -1)
1493 cursor[i].fClusterStart = j;
1498 emax = entries[j + 1] - 1;
1499 if (!elist->
ContainsRange(entries[j]+chainOffset,emax+chainOffset))
1503 if (
b->fCacheInfo.HasBeenUsed(j) ||
b->fCacheInfo.IsInCache(j) ||
b->fCacheInfo.IsVetoed(j)) {
1506 if (showMore ||
gDebug > 7)
1507 Info(
"FillBuffer",
"Skipping basket to avoid redo: %d/%d veto: %d", i, j,
b->fCacheInfo.IsVetoed(j));
1511 if (std::find(std::begin(potentialVetoes), std::end(potentialVetoes), j) != std::end(potentialVetoes)) {
1518 b->fCacheInfo.Veto(j);
1519 if (showMore ||
gDebug > 7)
1520 Info(
"FillBuffer",
"Veto-ing cluster %d [%lld,%lld[ in branch %s #%d", j, entries[j],
1521 maxOfBasket(j) + 1,
b->GetName(), i);
1526 if ((((entries[j] > entry)) || (j < nb - 1 && entries[j + 1] <= entry))) {
1528 if (j == cursor[i].fClusterStart && entry > entries[j])
1530 if (entries[j] > entry)
1539 if (clusterIterations > 0 && cursor[i].fLoadedOnce) {
1543 if (showMore ||
gDebug > 5) {
1546 "Breaking early because %lld is greater than %d at cluster iteration %d will restart at %lld",
1553 if (pass == kStart || !cursor[i].fLoadedOnce) {
1561 if (showMore ||
gDebug > 5) {
1562 Info(
"FillBuffer",
"Breaking early because %lld is greater than 4*%d at cluster iteration "
1563 "%d pass %d will restart at %lld",
1575 if (showMore ||
gDebug > 5) {
1576 Info(
"FillBuffer",
"Breaking early because %lld is greater than 2*%d at cluster iteration "
1577 "%d pass %d will restart at %lld",
1589 reqRanges.Update(i, j, entries, nb,
fEntryMax);
1590 if (showMore ||
gDebug > 6)
1591 ranges.Update(i, j, entries, nb,
fEntryMax);
1593 b->fCacheInfo.SetIsInCache(j);
1595 if (showMore ||
gDebug > 6)
1596 Info(
"FillBuffer",
"*** Registering branch %d basket %d %s", i, j,
b->GetName());
1598 if (!cursor[i].fLoadedOnce) {
1599 cursor[i].fLoadedOnce =
true;
1603 perfStats->SetLoaded(i, j);
1610 ntotCurrentBuf =
fNtot;
1619 ntotCurrentBuf =
fNtot;
1622 if ( ( j < (nb-1) ) && entries[j+1] > maxReadEntry ) {
1624 maxReadEntry = entries[j+1];
1628 Warning(
"FillBuffer",
"There is more data in this cluster (starting at entry %lld to %lld, "
1629 "current=%lld) than usual ... with %d %.3f%% of the branches we already have "
1630 "%d bytes (instead of %d)",
1634 if (pass == kStart) {
1636 auto high = maxOfBasket(j);
1637 if (high < lowestMaxEntry)
1638 lowestMaxEntry = high;
1642 }
else if ((j + 1) == nb || entries[j + 1] >= maxReadEntry || entries[j + 1] >= lowestMaxEntry) {
1644 auto high = maxOfBasket(j);
1645 if (high < lowestMaxEntry)
1646 lowestMaxEntry = high;
1653 if (cursor[i].fCurrent == nb) {
1658 Info(
"CollectBaskets",
1659 "Entry: %lld, registering baskets branch %s, fEntryNext=%lld, fNseek=%d, ntotCurrentBuf=%d",
1663 skippedFirst = (nSkipped > 0);
1664 oncePerBranch = (nDistinctLoad ==
fNbranches);
1665 progress = nReadPrefRequest - oldnReadPrefRequest;
1672 full = CollectBaskets(kStart, kNarrow,
fEntryNext);
1676 while (!full && !reachedEnd && progress) {
1677 full = CollectBaskets(kStart, kFull, std::min(maxReadEntry,
fEntryNext));
1680 resetBranchInfo =
false;
1685 full = CollectBaskets(kRegular, kFull,
fEntryNext);
1686 }
while (!full && !reachedEnd && progress);
1690 if (!full && skippedFirst) {
1691 full = CollectBaskets(kRewind, kFull,
fEntryNext);
1692 while (!full && !reachedEnd && progress) {
1693 full = CollectBaskets(kRegular, kFull,
fEntryNext);
1697 clusterIterations++;
1699 minEntry = clusterIter.
Next();
1717 (prevNtot < ntotCurrentBuf) && (minEntry <
fEntryMax))) {
1718 if (showMore ||
gDebug > 6)
1719 Info(
"FillBuffer",
"Breaking because %d <= %lld || (%d >= %d) || %lld >= %lld",
fBufferSizeMin,
1720 ((
Long64_t)ntotCurrentBuf * (clusterIterations + 1)) / clusterIterations, prevNtot, ntotCurrentBuf,
1729 if (minEntry >= fEntryCurrentMax && fEntryCurrentMax > 0)
1737 if (showMore ||
gDebug > 6) {
1738 Info(
"FillBuffer",
"Mem ranges");
1740 Info(
"FillBuffer",
"Combined ranges");
1742 Info(
"FillBuffer",
"Requested ranges");
1747 if (nReadPrefRequest == 0) {
1751 if (showMore ||
gDebug > 5) {
1752 Info(
"FillBuffer",
"For entry %lld, nothing was added to the cache.", entry);
1754 }
else if (
fEntryNext < firstClusterEnd && !reqRanges.Contains(entry)) {
1766 if (showMore ||
gDebug > 5) {
1767 Error(
"FillBuffer",
"Reset the next entry because the currently loaded range does not contains the request "
1768 "entry: %lld. fEntryNext updated from %lld to %lld. %d",
1769 entry,
fEntryNext, firstClusterEnd, nReadPrefRequest);
1775 if (showMore ||
gDebug > 5) {
1776 Info(
"FillBuffer",
"Complete adding %d baskets from %d branches taking in memory %d out of %d",
1777 nReadPrefRequest, reqRanges.BranchesRegistered(), ntotCurrentBuf,
fBufferSizeMin);
1806 if (!(stcp =
gSystem->Getenv(
"ROOT_TTREECACHE_PREFILL")) || !*stcp) {
1807 s =
gEnv->GetValue(
"TTreeCache.Prefill", 1);
1902 printf(
"******TreeCache statistics for tree: %s in file: %s ******\n",
fTree ?
fTree->GetName() :
"no tree set",
fFile ?
fFile->GetName() :
"no file set");
1904 printf(
"Number of branches in the cache ...: %d\n",
fNbranches);
1905 printf(
"Cache Efficiency ..................: %f\n",
GetEfficiency());
1910 if ( opt.
Contains(
"cachedbranches") ) {
1912 printf(
"Cached branches....................:\n");
1915 for (
Int_t i = 0; i < nbranches; ++i) {
1917 printf(
"Branch name........................: %s\n",branch->
GetName());
1936 ::Info(
"TTreeCache::ReadBufferNormal",
"Cache miss after an %s FillBuffer: pos=%lld",
1937 bufferFilled ?
"active" :
"inactive", basketpos);
1938 for (
Int_t i = 0; i < branches->GetEntries(); ++i) {
1940 Int_t blistsize =
b->GetListOfBaskets()->GetSize();
1941 for (
Int_t j = 0; j < blistsize; ++j) {
1942 if (basketpos ==
b->GetBasketSeek(j)) {
1944 ::Info(
"TTreeCache::ReadBufferNormal",
" Missing basket: %d for %s", j,
b->GetName());
1958 else if (res == 0) {
1962 recordMiss(perfStats,
fBranches, bufferFilled, pos);
1975 recordMiss(perfStats,
fBranches, bufferFilled, pos);
2045 if (
b->GetDirectory()->GetFile() !=
fFile)
2047 b->fCacheInfo.Reset();
2080 if (res == 0 && buffersize <= prevsize) {
2115 Info(
"SetEntryRange",
"fEntryMin=%lld, fEntryMax=%lld, fEntryNext=%lld",
2118 if (needLearningStart) {
2266 if (entry < fEntryMin || entry >
fEntryMax)
return;
#define R__unlikely(expr)
int Int_t
Signed integer 4 bytes (int).
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
double Double_t
Double 8 bytes.
constexpr Ssiz_t kNPOS
The equivalent of std::string::npos for the ROOT class TString.
long long Long64_t
Portable signed long integer 8 bytes.
unsigned long long ULong64_t
Portable unsigned long integer 8 bytes.
const char Option_t
Option string (const char).
void Printf(const char *fmt,...)
Formats a string in a circular formatting buffer and prints the string.
A Branch for the case of an object.
A TTree is a list of TBranches.
@ kDoNotProcess
Active bit for branches.
A chain is a collection of files containing TTree objects.
<div class="legacybox"><h2>Legacy Code</h2> TEventList is a legacy interface: there will be no bug fi...
virtual bool ContainsRange(Long64_t entrymin, Long64_t entrymax)
Return TRUE if list contains entries from entrymin to entrymax included.
TFileCacheRead(const TFileCacheRead &)=delete
virtual Int_t ReadBuffer(char *buf, Long64_t pos, Int_t len)
Read buffer at position pos.
virtual void SecondPrefetch(Long64_t, Int_t)
Bool_t fEnablePrefetching
reading by prefetching asynchronously
Int_t fNtot
Total size of prefetched blocks.
virtual Int_t SetBufferSize(Long64_t buffersize)
Sets the buffer size.
virtual void Prefetch(Long64_t pos, Int_t len)
Add block of length len at position pos in the list of blocks to be prefetched.
Int_t fBufferSizeMin
Original size of fBuffer.
Bool_t fIsTransferred
True when fBuffer contains something valid.
TFile * fFile
Pointer to file.
Int_t fNseek
Number of blocks to be prefetched.
void Print(Option_t *option="") const override
Print cache statistics.
virtual Int_t GetBufferSize() const
virtual void SetFile(TFile *file, TFile::ECacheAction action=TFile::kDisconnect)
Set the file using this cache and reset the current blocks (if any).
A file, usually with extension .root, that stores data and code in the form of serialized objects in ...
virtual void SetCacheRead(TFileCacheRead *cache, TObject *tree=nullptr, ECacheAction action=kDisconnect)
Set a pointer to the read cache.
ECacheAction
TTreeCache flushing semantics.
A TFriendElement TF describes a TTree object TF in a file.
virtual TTree * GetTree()
Return pointer to friend TTree.
A TLeaf describes individual elements of a TBranch See TBranch structure in TTree.
virtual TLeaf * GetLeafCount() const
If this leaf stores a variable-sized array or a multi-dimensional array whose last dimension has vari...
TBranch * GetBranch() const
const char * GetName() const override
Returns name of object.
Int_t GetEntriesFast() const
TObject * UncheckedAt(Int_t i) const
Collectable string class.
const char * GetName() const override
Returns name of object.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Regular expression class.
void ToLower()
Change string to lower-case.
Int_t Atoi() const
Return integer value of string.
const char * Data() const
TString & ReplaceAll(const TString &s1, const TString &s2)
TString & Append(const char *cs)
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
virtual void SetLearnPrefill(EPrefillType type=kNoPrefill)
Set whether the learning period is started with a prefilling of the cache and which type of prefillin...
virtual void UpdateBranches(TTree *tree)
Update pointer to current Tree and recompute pointers to the branches in the cache.
Double_t GetEfficiencyRel() const
This will indicate a sort of relative efficiency... a ratio of the reads found in the cache to the nu...
bool fEnabled
! cache enabled for cached reading
Long64_t fLastMiss
! set to the event # of the last miss.
Int_t fNMissReadPref
Number of blocks read into the secondary ("miss") cache.
~TTreeCache() override
Destructor. (in general called by the TFile destructor).
Int_t fNMissReadOk
Number of blocks read, not found in the primary cache, and found in the secondary cache.
Int_t SetBufferSize(Long64_t buffersize) override
Change the underlying buffer size of the cache.
Long64_t fEntryMin
! first entry in the cache
void SetOptimizeMisses(bool opt)
Start of methods for the miss cache.
Int_t LearnBranch(TBranch *b, bool subgbranches=false) override
Add a branch discovered by actual usage to the list of branches to be stored in the cache this functi...
static void SetLearnEntries(Int_t n=10)
Static function to set the number of entries to be used in learning mode The default value for n is 1...
bool CheckMissCache(char *buf, Long64_t pos, int len)
Check the miss cache for a particular buffer, fetching if deemed necessary.
Long64_t fEntryNext
! next entry number where cache must be filled
Int_t fNReadMiss
Number of blocks read and not found in the cache.
bool fReverseRead
! reading in reverse mode
Double_t GetEfficiency() const
Give the total efficiency of the primary cache... defined as the ratio of blocks found in the cache v...
virtual bool FillBuffer()
Fill the cache buffer with the branches in the cache.
Long64_t fNextClusterStart
! End+1 of the cluster(s) where the current content was picked out
bool ProcessMiss(Long64_t pos, int len)
! Given a file read not in the miss cache, handle (possibly) loading the data.
const TObjArray * GetCachedBranches() const
bool fIsLearning
! true if cache is in learning mode
Int_t fNMissReadMiss
Number of blocks read and not found in either cache.
IOPos FindBranchBasketPos(TBranch &, Long64_t entry)
Given a branch and an entry, determine the file location (offset / size) of the corresponding basket.
virtual void SetEntryRange(Long64_t emin, Long64_t emax)
Set the minimum and maximum entry number to be processed this information helps to optimize the numbe...
TTreeCache()
Default Constructor.
std::unique_ptr< MissCache > fMissCache
! Cache contents for misses
bool fFirstBuffer
! true if first buffer is used for prefetching
bool fOptimizeMisses
! true if we should optimize cache misses.
void StartLearningPhase()
The name should be enough to explain the method.
TBranch * CalculateMissEntries(Long64_t, int, bool)
Given an file read, try to determine the corresponding branch.
Long64_t fCurrentClusterStart
! Start of the cluster(s) where the current content was picked out
Double_t GetMissEfficiency() const
The total efficiency of the 'miss cache' - defined as the ratio of blocks found in the cache versus t...
virtual Int_t ReadBufferNormal(char *buf, Long64_t pos, Int_t len)
Old method ReadBuffer before the addition of the prefetch mechanism.
virtual void ResetCache()
This will simply clear the cache.
bool fOneTime
! used in the learning phase
EPrefillType fPrefillType
Whether a pre-filling is enabled (and if applicable which type).
bool fLearnPrefilling
! true if we are in the process of executing LearnPrefill
virtual void LearnPrefill()
Perform an initial prefetch, attempting to read as much of the learning phase baskets for all branche...
virtual Int_t DropBranch(TBranch *b, bool subbranches=false)
Remove a branch to the list of branches to be stored in the cache this function is called by TBranch:...
Long64_t fEntryMax
! last entry in the cache
static Int_t fgLearnEntries
number of entries used for learning mode
virtual Int_t ReadBufferPrefetch(char *buf, Long64_t pos, Int_t len)
Used to read a chunk from a block previously fetched.
Long64_t fEntryCurrent
! current lowest entry number in the cache
void ResetMissCache()
Reset all the miss cache training.
Long64_t fFirstMiss
! set to the event # of the first miss.
Int_t ReadBuffer(char *buf, Long64_t pos, Int_t len) override
Read buffer at position pos if the request is in the list of prefetched blocks read from fBuffer.
bool fReadDirectionSet
! read direction established
bool fIsManual
! true if cache is StopLearningPhase was used
Double_t GetMissEfficiencyRel() const
Relative efficiency of the 'miss cache' - ratio of the reads found in cache to the number of reads so...
Long64_t fFirstEntry
! save the value of the first entry
Int_t fFillTimes
! how many times we can fill the current buffer
Int_t fNReadPref
Number of blocks that were prefetched.
TTree * fTree
! pointer to the current Tree
EPrefillType GetConfiguredPrefillType() const
Return the desired prefill type from the environment or resource variable.
static Int_t GetLearnEntries()
Static function returning the number of entries used to train the cache see SetLearnEntries.
virtual void StopLearningPhase()
This is the counterpart of StartLearningPhase() and can be used to stop the learning phase.
void SetFile(TFile *file, TFile::ECacheAction action=TFile::kDisconnect) override
Change the file that is being cached.
Int_t fNbranches
! Number of branches in the cache
Int_t fNReadOk
Number of blocks read and found in the cache.
void Print(Option_t *option="") const override
Print cache statistics.
Int_t AddBranch(TBranch *b, bool subgbranches=false) override
Add a branch to the list of branches to be stored in the cache this function is called by the user vi...
TObjArray * fBranches
! List of branches to be stored in the cache
TList * fBrNames
! list of branch names in the cache
bool fFirstTime
! save the fact that we processes the first entry
Helper class to iterate over cluster of baskets.
Long64_t Next()
Move on to the next cluster and return the starting entry of this next cluster.
A TTree represents a columnar dataset.
virtual TVirtualPerfStats * GetPerfStats() const
virtual TClusterIterator GetClusterIterator(Long64_t firstentry)
Return an iterator over the cluster of baskets starting at firstentry.
virtual TObjArray * GetListOfLeaves()
virtual Long64_t GetEntries() const
virtual Long64_t GetReadEntry() const
virtual TTree * GetTree() const
virtual Long64_t GetAutoFlush() const
Provides the interface for the an internal performance measurement and event tracing.
virtual void SetMissed(TBranch *b, size_t basketNumber)=0
virtual void UpdateBranchIndices(TObjArray *branches)=0
void Print(std::ostream &os, const OptionType &opt)
__device__ AFloat max(AFloat x, AFloat y)
Long64_t BinarySearch(Long64_t n, const T *array, T value)
Binary search in an array of n values to locate value.
Int_t fLen
! Length of cache entry.
Long64_t fPos
! Position in file of cache entry.