Make using DataSource faster by using lazy reading#949
Make using DataSource faster by using lazy reading#949
Conversation
|
When I initially designed the whole Frame infrastructure, I had the following idea for reading data lazily: Construct some form of From the looks of your version here callback goes pretty much in that direction, only that the logic still lives in the Reader and that there is a condition of not going to the next entry before all collections have been lazily read. To make this more generic one would have to probably add
Purely from not overloading the existing reader with too much functionality, I would be in favor of having the details of lazy or eager reading entirely hidden behind the existing interface of As a side note some of the excessive data loading could be front-loaded to the users for a quick work around, because |
The problem of
DataSourceis that everything is being loaded all the time, unlike for traditionalRDataFrames. I have added lazy reading toROOTReaderandRNTupleReader, which have to be different because the internals of the readers are different. ForROOTReaderit is relatively trivial with a callback, we just read the collection that we need when it is used; forRNTupleReaderwe create a new ROOTRNTupleReaderwith a minimal model for each collection since the complete model is fixed at the beginning (the key difference is: forROOTReaderwe have one branch for each collection and we read per-branch, forRNTupleReaderwe have the full model). Possible questions and comments:ROOTReaderassumes all reading for an event is done before moving on to the next one, which is something that would have to be changed.DataSource, since it does not work in the general case (at least forROOTReader, explained above).Benchmarks later but I can read a few GB of TTree and RNTuple files in a close time to using RDataFrame directly on them (tested with single threading only, I think multithreading should bring a similar speedup since
DataSourcemakes several independent readers).BEGINRELEASENOTES
DataSourcelook more like the two existing implementations (https://root.cern/doc/v638/classROOT_1_1RDF_1_1RCsvDS.html and https://root.cern/doc/v638/classROOT_1_1RDF_1_1RNTupleDS.html).master(it seems resolving relations is not correct).ENDRELEASENOTES