Repository navigation
Description
Describe the bug, including details regarding any error messages, version, and platform.
I run pretty straight forward usage of read_parquet in several workflows at work. This has been a tremendous upgrade from using rds files with the same content for all the reasons arrow exists. Some of our datasets are wider than longer, which isnt great for parquet, but we usually only need a small subset.
I updated to arrow v11.0.0.2 yesterday and noticed that the identical workflows are loading files 50-60x slower.
A benchmark are selectively choosing 200 columns from a (3400 rows x 16000 column dataset, each column containing two text attributes)
~300ms with 9.0.0
~17000ms using v11.0.0.2.
Ubuntu 8-core intel i7
If I save the file I read from v9 saving with v11, then re-read with v11, it's the same , ~17 seconds
On the mac (M1 10-core) it's about 12 seconds.
I understand there are some significant changes under the hood with c++ under the v10 updates but based on the update notes no action would be required for doing anything fancy with ubuntu (I have gcc v9.4) or mac (clang v13).
Any idea what's going on? We store thousands of parquet files so wondering if we should avoid >= v11.
Sorry if this is mislabeled as a bug, but it seems like one to me as I havent changed anything else but systems meet the requirements.
here's a reprex:
library(arrow)
library(microbenchmark)
# fake data, 3500x16000 with attributes
test_data <- as.data.frame(
lapply(setNames(1:16000, paste0("col", 1:16000)), function(x) {
col <- sample(c(1:5, NA), 3500, replace = TRUE)
levels(col) <- paste("level", 1:4)
attr(col, "text") <- "test question text"
col
})
)
# write out the file somewhere
file <- "~/Desktop/test_data_v9.parquet"
### using arrow 9.0.0
packageVersion('arrow')
arrow::write_parquet(test_data, file)
### benchmark
microbenchmark::microbenchmark(
arrow::read_parquet(file, col_select = 1:200), times = 10
)
### NOW SWITCH to arrow 11.0.0.2 just from the 9.0.0 data
packageVersion('arrow')
microbenchmark::microbenchmark(
arrow::read_parquet(file, col_select = 1:200), times = 10
)
### now re-create, save, re-read using all v11
packageVersion('arrow')
file2 <- "~/Desktop/test_data_v11.parquet"
arrow::write_parquet(test_data, file2)
### benchmark
microbenchmark::microbenchmark(
arrow::read_parquet(file2, col_select = 1:200), times = 10
)
Component(s)
R
Activity
assignUser commentedon Feb 24, 2023
Hello thanks for the detailed report!
I am able to reproduce the issue, my times are overall a bit faster (192ms for 9.0.0 read) but 192ms -> 5s is still an unacceptable regression.
assignUser commentedon Feb 24, 2023
Actually same issue exists in 10.0.0
assignUser commentedon Feb 24, 2023
col_select does not make a difference which I am pretty sure it should?
[-]v11.0.0.2 extremely slow with parquet files written in v9.0.0[/-][+][R] v11.0.0.2 extremely slow with parquet files written in v9.0.0[/+]assignUser commentedon Feb 24, 2023
I get the same slow 6 seconds for 9.0.0 when I remove col_select, so it seems the issue existed before but was hidden for small number of cols.
devinrkeane commentedon Feb 24, 2023
thanks for responding so quickly! yeah I also tried with 20 columns and it didnt seem to affect anything performance wise, which previously (and expected) did matter a great deal.
jorisvandenbossche commentedon Feb 24, 2023
I don't directly see a similar issue with pyarrow. Using the low-level reader (and a private method to be able to pass column indices directly instead of column names, to mimic what happens in R):
That's with pyarrow 9.0, and I see basically the same for pyarrow 10.0.
So maybe something changed with how the
col_selectkeyword is being used?westonpace commentedon Feb 24, 2023
Yes, I think so. @assignUser and I discussed this externally and noticed that the slowdown is likely R-specific
paleolimbot commentedon Feb 24, 2023
It's almost certainly these two lines:
arrow/r/R/parquet.R
Lines 56 to 59 in 1c483e4
It's a little complicated to support both dplyr-like selection and speed here. Perhaps we need a workaround (like
col_select = I(1:200)) to signal that a user wants to circumvent dplyr syntax sugar here?paleolimbot commentedon Mar 9, 2023
A good workaround is probably just to use the
ParquetFileReaderdirectly:Perhaps the best fix here is a docs fix to suggest that this is possible/desirable? I would prefer that to adding more complexity to the implementation.
jorisvandenbossche commentedon Apr 6, 2023
Is this something that is critical for 12.0?
thisisnic commentedon Apr 6, 2023
@jorisvandenbossche It's not a blocker as we have a workaround.
thisisnic commentedon Sep 24, 2026
Note: this comment was written by Claude Code (an AI assistant) at my request, after I asked it to check whether this issue still applies. I have reviewed the findings but the measurements and analysis are its own.
I re-ran this on current main (1f789ff) to see whether it still applies. The short answer is that the
col_selectregression described in the original report is gone, but the reproducer is still slow for a different reason.With 16000 plain integer columns and no attributes,
read_parquet(file, col_select = 1:200)takes about 0.15 s and reading all columns takes about 0.27 s. So theeval_selectpath that was suspected above is no longer a problem.The reproducer in this issue attaches
levelsandtextattributes to every column, and that is where the time now goes. With 16000 such columns and 10 rows:as.data.frame(reader$ReadTable(1:200))read_parquet(file, col_select = 1:200)tab$metadata$ralone, on the 200 column tableread_parquet(file), all columnsTwo separate costs, both in R metadata handling and both scaling with the number of columns in the file rather than the number selected:
Unserialising and sanitising the R metadata costs about 1.2 s per read regardless of
col_select, because the table still carries metadata for all 16000 columns andsafe_r_metadata()walks all of it in R:arrow/r/R/metadata.R
Line 73 in 1f789ff
ParquetFileReaderworkaround above no longer helps much for data like this.Applying the per-column metadata costs a further 9 s when reading all columns, because the loop assigns into the data frame with
x[[name]] <-on every iteration, copying the whole 16000 column frame each time:arrow/r/R/metadata.R
Lines 178 to 182 in 1f789ff
I think this should stay open, but the title no longer describes the problem. Suggest retitling to something like "[R] Reading wide files with per-column R metadata is slow" and treating the two costs above as the work items. The second one is a small fix: collect the modified columns and assign once after the loop.
[-][R] v11.0.0.2 extremely slow with parquet files written in v9.0.0[/-][+][R] Reading wide files with per-column R metadata is slow[/+]