Repository navigation
Improve parquet read implementation and multiple column read performance - #4906
Conversation
|
Thanks, @ajpotts and @jabraham17 @ajpotts / @jabraham17 : I will revert the configuration files. I am keeping them as is to make my life easier testing the branch on different systems. @jabraham17 : I resolved bunch of your comments with a new set of commits. Feel free to iterate through those to follow changes. Probably the first new commit is the most consequential one. I left some discussions unresolved because I either need some more clarifications, or prefer to do the changes you request in a subsequent PR out of paranoia + principle to not make nitty-gritty stylistic changes in this PR where big chunks of code being moved around and introduced. Let me know if you want to argue for urgency of those changes. One big item for me to try tomorrow is your suggestion to replace the symlink-based enum interop with... something more principled (I need to remember the idea by going through our Slack convo). But feel free to chime in on the unresolved discussions in the meantime. |
|
I will do my testing after rebasing on |
I think many of my comments were about improving the quality of the code, both for developer readability and maintainability/future extensibility. I am perfectly happy with those comments being addressed in a future PR |
ajpotts
left a comment
There was a problem hiding this comment.
Before I can merge this we need to figure out why I can't compile this PR on my Ubuntu box.
30c4b8c to
c1065b2
Compare
c1065b2 to
62e4f7d
Compare
Signed-off-by: Engin Kayraklioglu <[email protected]>
38de895 to
fd11a12
Compare
This PR has two main goals:
User-facing Change:
has_non_float_nulls: Bool, in favor ofnull_handling: {"none", "only floats", "all"}null_handlingformal toread_parquetdefaults to "only floats" to match with the older behavior.null_handlingis effective only when reading all columns.has_non_float_nullsis used when only a subset of columns are read. It is a TODO to phase outhas_non_float_nulls, among other things.Why do we need a new implementation for performance?
Parquet is a columnar format. However, that doesn't mean that all data for a column is stored consecutively. For large files (512M by default, I think), Parquet files will be written in consecutive row groups instead of storing large columns one after another. Therefore, a more natural way of reading a parquet file is to read row-group-by-row-group while going through all the columns. Considering reading all columns as a common use case, it is important to read parquet files in that way for performance. Right now, if you have 10 columns, you open and read the entire file(s) 10 times, one for each column, skipping 9 columns during each read.
A small optimization along the way
With the new
null_handlingcontrol flag, we can also enable batch reads of floating point types where prior to this PR we were reading them one-by-one to be able to catch nulls. I think even with nulls at play, we should be able to do better than that, but that's a post-merge TODO.Performance Improvements
This is using ~400GBs of data in 5 columns partitioned into 128 files, read by 16 locales:
main(s)This is using ~30GBs of data in 1000 columns partitioned into 128 files, read by 16 locales:
master(s)Implementation details:
read_parquet, we read all columns. This PR makes that case take an entirely new codepath with no modifications to the subset-of-columns code path. I intend to remove this old code path in favor of the new one even for subset-of columns. That's a post-merge TODO.namespace akcppon the C++ side. I want more code to live in this namespace going forward. Within that namespace:struct AkReadColOpon the C++ side to represent type-agnostic information for reading a single column.read()function for reading a column with specific dynamic typeread()has some template specializations for handling some specific cases like short integrals that are not represented on the Chapel side and need to be cast to bigger onesread()family of functions has a lot of code redundancy that I inherited from the earlier implementation. Refactoring those redundancies into helpers is an obvious TODO.readAllColsfunction to handle the operation. This is the function that selects the correctread()instantiation based on the dynamic type.readAllColsParquetMsgwhich is the main message handler here. The implementation is too much of a Frakenstein experiment where old style/structure is mixed with the new. Going forward, I want this function to be the general parquet read function, so it needs more improvements.pqReadColOp. This is deceptively similar toAkReadColOp. But it actually stores information for the whole read operation and it is not per-column. I want to consider whether we can have single metadata shared between C++ and Chapel.pqReadColOpdetermines whether we can read all columns at the same time based on the dynamic types of the columns. If we can't it will fall back to the old implementation. Currently that fallback is a bit rough as we call the message handler. I think that's a bad practice and the core logic of the read has to be available without the message handling. We'll need to reconcile the two different reads in any case, so that's part of post-merge TODOs.pqReadColOpto be more generic than I'd like. It will be fixed in the next refactor wave.Test Status:
Post-Merge TODO
read()functions into having more helpersakcpp::readAllColsfunction for reading subset of columns, too and remove the old read implementation completely. Similarly forreadAllColsParquetMsgon Chapel sidehas_non_float_nullsARROWERRORand error messages populated by the C level better and more consistentlystrict_typesargument from the Parquet interface #4925