-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Memory Consumption when performing a left_join()
#434
Comments
Thanks, we need to work on the docs here. Can you try: duck_exec("set memory_limit='1GB'") or a similar value? |
Mmmhhh.... I added that line just after loading the duckplyr library, but I still have the RAM consumption going through the roof of my system. |
Thanks. The session info indicates you're using arrow 15.0.1, but it doesn't tell which version of duckdb is installed. Can you please double-check with the latest, 1.1.3-1? |
Hello, duckdb was automagically installed when I installed duckplyr. From a more explicit sessioninfo() (loading duckdb and duckplyr) I see this
So I am not using an outdated version of duckdb. |
Thanks, confirming that, on a VM with 4 GB with Debian Bookworm running in OrbStack, the following example is killed: options(conflicts.policy = list(warn = FALSE))
library(dplyr)
library(duckplyr)
library(readr)
if (!file.exists("test.csv")) {
dd <- tibble(x=1:100000000, y=rep(LETTERS[1:20], 5000000))
write_csv(dd, "test.csv")
}
duck_exec("set memory_limit='1GB'")
df <- duck_csv("test.csv")
df_stat <- df |>
summarise(total=sum(x), .by = y)
df_out <- df |>
left_join(y=df_stat, by=c("y")) |>
collect()
df_out |
left_join()
I see. I have 8Gb in my machine and I opened the issue because I can run the code with arrow on my machine (with some difficulties), but not with duckplyr. No intention to start a competition between the two tools, but I assumed there may be a memory leak in duckplyr |
Thanks. Could be related to the following phenomenon, which I'd classify as a bug. I'd expect options(conflicts.policy = list(warn = FALSE))
library(dplyr)
library(duckplyr)
duck_tbl(a = 1) |>
collect() |>
class()
#> [1] "duckplyr_df" "tbl_df" "tbl" "data.frame"
duck_tbl(a = 1, .lazy = TRUE) |>
collect() |>
class()
#> [1] "duckplyr_df" "tbl_df" "tbl" "data.frame" Created on 2025-01-02 with reprex v2.1.1 |
To finish this off on my side: if I kill almost any other process, duckplyr also gets the job done on my machine, but the memory consumption is significantly higher than under arrow. |
I'm no longer sure that The following example works, even with 4 GB: options(conflicts.policy = list(warn = FALSE))
library(dplyr)
library(duckplyr)
library(readr)
if (!file.exists("test.csv")) {
dd <- tibble(x=1:100000000, y=rep(LETTERS[1:20], 5000000))
write_csv(dd, "test.csv")
}
duck_exec("set memory_limit='1GB'")
df <- duck_csv("test.csv")
df_stat <- df |>
summarise(total=sum(x), .by = y)
df_out <-
df |>
left_join(y=df_stat, by=c("y")) |>
compute_parquet("test.parquet")
df_out Perhaps you can also use The large memory consumption is still interesting, though. |
Thanks. I now also have the procedure to convert a csv into an parquet file without ingesting everything into memory. |
Hello,
Please have a look at the reprex at the end of the file.
I have a seasoned laptop with 8Gb of RAM which runs debian stable.
When I carry out an aggregation and then a left join with arrow, I need to use some swap when I collect the result (a long dataframe), but I can run the computation.
Instead, if just run the part in duckplyr (commented out in the second part of the reprex), my memory is so insufficient that the laptop freezes. Can someone take a look into this? Is there a much higher memory consumption in duckplyr wrt arrow? Thanks a lot.
Created on 2025-01-01 with reprex v2.1.0
The text was updated successfully, but these errors were encountered: