Skip to content

Commit e09dc56

Browse files
authored
[nfc][tree] Clarify prefetch behavior
#16640 (comment)
1 parent 4254e9d commit e09dc56

File tree

3 files changed

+23
-6
lines changed

3 files changed

+23
-6
lines changed

config/rootrc.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,9 @@ RSA.KeyType: 1
452452

453453
# Control the usage of asynchronous prefetching capabilities irrespective
454454
# of the TFile implementation. By default it is disabled.
455+
# In conjunction with a TFileCacheRead (for example the TTreeCache), it
456+
# will asynchronously grab early the compressed data of the 'next' cluster
457+
# while the current cluster is being processed (ie is subject of GetEntry)
455458
#TFile.AsyncPrefetching: no
456459

457460
# Enable cross-protocol redirects

tree/tree/inc/TTree.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,11 @@ class TTree : public TNamed, public TAttLine, public TAttFill, public TAttMarker
687687
virtual void SetCacheLearnEntries(Int_t n=10);
688688
virtual void SetChainOffset(Long64_t offset = 0) { fChainOffset=offset; }
689689
virtual void SetCircular(Long64_t maxEntries);
690+
/// Enables (or disables) the early decompression of the baskets of the current cluster
691+
/// (whose compressed data is already in memory if used in conjunction with the TTreeCache).
692+
/// This affects performance only in conjunction with non-sequential use/load/read of the entries, ie
693+
/// within a cluster you can have cheap random access to the entries (instead of having to decompress again and again).
694+
/// \note This setting is totally different from SetCacheSize and from TFile.AsyncPrefetching, which save read calls
690695
virtual void SetClusterPrefetch(bool enabled) { fCacheDoClusterPrefetch = enabled; }
691696
virtual void SetDebug(Int_t level = 1, Long64_t min = 0, Long64_t max = 9999999); // *MENU*
692697
virtual void SetDefaultEntryOffsetLen(Int_t newdefault, bool updateExisting = false);

tree/tree/src/TTree.cxx

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5477,7 +5477,7 @@ Int_t TTree::GetBranchStyle()
54775477
////////////////////////////////////////////////////////////////////////////////
54785478
/// Used for automatic sizing of the cache.
54795479
///
5480-
/// Estimates a suitable size for the tree cache based on AutoFlush.
5480+
/// Estimates a suitable size in bytes for the tree cache based on AutoFlush.
54815481
/// A cache sizing factor is taken from the configuration. If this yields zero
54825482
/// and withDefault is true the historical algorithm for default size is used.
54835483

@@ -8876,14 +8876,18 @@ void TTree::SetBranchStyle(Int_t style)
88768876
}
88778877

88788878
////////////////////////////////////////////////////////////////////////////////
8879-
/// Set maximum size of the file cache .
8879+
/// Set maximum size of the file cache (TTreeCache) in bytes.
88808880
//
8881-
/// - if cachesize = 0 the existing cache (if any) is deleted.
8881+
/// - if cachesize = 0 the existing cache (if any) is disabled (deleted if any).
8882+
/// - if cachesize > 0, the cache is enabled or extended, if necessary
88828883
/// - if cachesize = -1 (default) it is set to the AutoFlush value when writing
88838884
/// the Tree (default is 30 MBytes).
88848885
///
88858886
/// The cacheSize might be clamped, see TFileCacheRead::SetBufferSize
88868887
///
8888+
/// TTreeCache's 'real' job is to actually prefetch (early grab from disk) the compressed data.
8889+
/// The cachesize controls the size of the read bytes from disk.
8890+
///
88878891
/// Returns:
88888892
/// - 0 size set, cache was created if possible
88898893
/// - -1 on error
@@ -8897,20 +8901,25 @@ Int_t TTree::SetCacheSize(Long64_t cacheSize)
88978901
}
88988902

88998903
////////////////////////////////////////////////////////////////////////////////
8900-
/// Set the size of the file cache and create it if possible.
8904+
/// Set the maximum size of the file cache (TTreeCache) in bytes and create it if possible.
89018905
///
89028906
/// If autocache is true:
89038907
/// this may be an autocreated cache, possibly enlarging an existing
89048908
/// autocreated cache. The size is calculated. The value passed in cacheSize:
8905-
/// - cacheSize = 0 make cache if default cache creation is enabled
8909+
/// - cacheSize = 0 make cache if default cache creation is enabled.
8910+
/// - cachesize > 0 the cache is enabled or extended, if necessary
89068911
/// - cacheSize = -1 make a default sized cache in any case
89078912
///
89088913
/// If autocache is false:
89098914
/// this is a user requested cache. cacheSize is used to size the cache.
8910-
/// This cache should never be automatically adjusted.
8915+
/// This cache should never be automatically adjusted. If cachesize is
8916+
/// 0, the cache is disabled (deleted if any).
89118917
///
89128918
/// The cacheSize might be clamped, see TFileCacheRead::SetBufferSize
89138919
///
8920+
/// TTreeCache's 'real' job is to actually prefetch (early grab from disk) the compressed data.
8921+
/// The cachesize controls the size of the read bytes from disk.
8922+
///
89148923
/// Returns:
89158924
/// - 0 size set, or existing autosized cache almost large enough.
89168925
/// (cache was created if possible)

0 commit comments

Comments
 (0)