pin_upload memory use grows with file size
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 78/100
Direzione di ricerca
Inizia leggendo Version.from_files e Version.hash_file, che l’issue identifica come probabile causa del picco di memoria. Controlla come viene usato block_size e perché il suo valore predefinito è -1, poi esegui i test pertinenti di hash e caricamento. Il lavoro è completato quando il caricamento di un file grande usa una quantità di memoria pressoché costante, preservando l’hash di versione del pin previsto.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Scenario
I use Polars to process data frames that are larger than available memory. Polars streams the work and writes the result straight to a parquet file on disk, so the data is never fully in memory. The file is published with pin_upload to an S3 board.
We expected the upload to stream the file as well. Instead, memory use during pin_upload grows with the file size. Our largest file is larger than available memory and the process is killed during the upload.
From a quick look, the spike seems to come from computing the pin version hash. Version.from_files calls Version.hash_file without a block_size, and the default of -1 reads the whole file in one call. hash_file already loops over chunks, so passing a fixed block_size, or changing the default, might be enough. I may be missing context on why the default is -1.
Reproducible example
import os
import resource
import tempfile
import pins
with tempfile.TemporaryDirectory() as d:
path = os.path.join(d, "big.bin")
with open(path, "wb") as f:
for _ in range(1024): # 1 GiB, written in 1 MiB chunks
f.write(os.urandom(1024**2))
before = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
board = pins.board_temp()
board.pin_upload(paths=[path], name="big")
after = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
print(f"peak RSS before: {before}, after: {after}") # grows by about 1 GiB
On macOS (ru_maxrss is in bytes), peak RSS grows from about 35 MiB to about 1,059 MiB. When hash_file is patched to use an 8 MiB block_size, the peak only reaches about 50 MiB.
Expected behavior
Uploading a file should use roughly constant memory regardless of file size.
Environment
- pins 0.9.2
- Python 3.12
- S3 board through s3fs
- Lingua principale
- Python
- Stelle
- 59
- Fork
- 11
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di rstudio/pins-python
-
.maint
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
rstudio/pins-python#280 ·
-
testing
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
rstudio/pins-python#196 ·
-
.enhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
rstudio/pins-python#363 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 55/100
rstudio/pins-python#354 ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 55/100
rstudio/pins-python#352 ·
Tutte le issue di rstudio/pins-python
Issue simili
-
docs(contributing): the two things that silently block a PRForse già presa Una pull request collegata a questa issue è aperta o già unita. Apertaavailable documentation good first issue
Difficoltà 1/5 1-3 ore Idoneità per principianti 95/100
Nixitov/Riptide-Native#944 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
JTHCode/secretguard#24 ·
I maintainer di solito rispondono entro 1 giorno
-
area: middleware documentation good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
-
enhancement good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno
-
good first issue
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 95/100
omarelshamy25x/shamy-hijri#63 ·
I maintainer di solito rispondono entro 1 giorno