Repository navigation
GH-48057: [R] Slow reading performance caused by apply_arrow_r_metadata() looping through all columns, including NULL ones - #48104
Conversation
|
|
|
Bit of a weird one to write tests for, so I just ran microbenchmarks using the code supplied by the user on the linked issue. Running user-supplied reprex on main branch without this change: Then, with it: |
| if (is.data.frame(x)) { | ||
| # if columns metadata exists, apply it here | ||
| if (length(names(x)) && !is.null(columns_metadata)) { | ||
| if (length(names(x)) && !is.null(columns_metadata) && !all(map_lgl(columns_metadata, is.null))) { |
There was a problem hiding this comment.
I know we don't want to benchmark this in our code, but this looks like something we want a test for, yeah?
There was a problem hiding this comment.
Oops, didn't think it was testable, but it totally is; added!
| expect_identical(df_no_metadata, df_with_metadata) | ||
|
|
||
| # with more complex column metadata - it preserves it | ||
| spicy_df_arrow <- arrow_table(haven_data) |
jonkeane
left a comment
There was a problem hiding this comment.
One small addition, but good otherwise
| }) | ||
|
|
||
| test_that("apply_arrow_r_metadata doesn't add in metadata from plain data.frame objects", { | ||
| # with just a plain df the (empty) column metadata is not preserved |
There was a problem hiding this comment.
Mind adding the issue number to this comment?
|
After merging your PR, Conbench analyzed the 4 benchmarking runs that have been run so far on merge-commit 9ea91ca. There were no benchmark performance regressions. 🎉 The full Conbench report has more details. It also includes information about 1 possible false positive for unstable benchmarks that are known to sometimes produce them. |
…metadata() looping through all columns, including NULL ones (apache#48104) ### Rationale for this change Slow reading due to looping through metadata ### What changes are included in this PR? Don't loop through NULL metadata ### Are these changes tested? Not in unit tests, but see comment below with microbenchmarks. ### Are there any user-facing changes? No * GitHub Issue: apache#48057 Authored-by: Nic Crane <thisisnic@gmail.com> Signed-off-by: Nic Crane <thisisnic@gmail.com>
Rationale for this change
Slow reading due to looping through metadata
What changes are included in this PR?
Don't loop through NULL metadata
Are these changes tested?
Not in unit tests, but see comment below with microbenchmarks.
Are there any user-facing changes?
No
apply_arrow_r_metadata()looping through all columns, including NULL ones #48057