apache / apache/arrow

[R] arrow::open_dataset %>% select(myvars) %>% collect causes memory leak

Offen
#33,366 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Priority: Critical Type: bug
Vorherrschende Sprache
C++
Sterne
17.1k
Forks
4.3k
Ø Merge
3 T. 23 Std.
Gemergte PRs (30 T.)
101

Beschreibung

I first posted on StackOverlow, [here.](https://stackoverflow.com/questions/74221492/r-arrow-open-dataset-selectmyvars-collect-causing-memory-leak)

I am having trouble using arrow in R. First, I saved some `data.tables` that were about 50-60Gb (`{}d{`} in the code chunk) in memory to a parquet file using:
 
`d %>% write_dataset(f, format='parquet') # f is the directory name`

Then I try to read open the file, select the relevant variables and
 
`tic()d2 <- open_dataset(f) %>% select(all_of(myvars)) %>% collect #myvars is a vector of variable namestoc()`

I did this conversion for 3 sets of data.tables (unfortunately, data is confidential so I can't include in the example). In one set, I was able to `open>select>collect` the desired table in about 60s, obtaining a 10Gb file (after variable selection).

For the other two sets, the command caused a memory leak. tic()-toc() returned after 80s. But the object name (d2) never appeared in Rstudio's "Enviroment panel", and memory used keeps creeping up until it occupied most of the available RAM of the server, and then R crashed. Note the orginal dataset, without subsetting cols, was smaller than 60Gb and the server had 512GB.

Any ideas on what could be going on here?

UPDATE: today I noticed a few more things.

1) If the collected object is small enough (3 cols, 66million rows), R will unfreeze. The console becomes responsive, the object shows up in the Environment panel. But memory use keeps going up (by small amounts because the underlying that is small). While this is helpening, issuing a gc() command reduces the memory use, but it then starts growing again.

2) Even after "rm(d2)" and  "gc()", the R session that issued the arrow commands still use around 60-70Gb of RAM... The only way to end that is to close the R session. 

3) I am using arrow 10.0.0

 

 

 

**Reporter**: [Lucas Mation](https://issues.apache.org/jira/browse/ARROW-18176) / @lucasmation
#### Related issues:
- [[R] Substantial RAM use increase in 9.0.0 release on write_dataset()](https://github.com/apache/arrow/issues/32795) (relates to)

**Note**: *This issue was originally created as [ARROW-18176](https://issues.apache.org/jira/browse/ARROW-18176). Please see the [migration documentation](https://github.com/apache/arrow/issues/14542) for further details.*

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne damit, den gemeldeten R-10.0.0-Workflow mit open_dataset(f) %>% select(all_of(myvars)) %>% collect zu reproduzieren, und verwende Datensätze, die groß genug sind, um das Speicherwachstum sichtbar zu machen. Im Issue werden keine Repository-Dateien oder Tests genannt; als abgeschlossen gilt die Aufgabe, wenn die Ursache des beibehaltenen Speichers identifiziert und nachgewiesen wurde, dass der Speicher nach dem Sammeln und der Bereinigung freigegeben wird.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
r
Bereich
data
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.