pin_upload memory use grows with file size
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 78/100
Línea de trabajo
Empieza leyendo Version.from_files y Version.hash_file, que el issue identifica como la fuente probable del aumento brusco del uso de memoria. Comprueba cómo se usa block_size y por qué su valor predeterminado es -1, y luego ejecuta las pruebas pertinentes de hash y carga. El objetivo se cumple cuando cargar un archivo grande usa una cantidad de memoria aproximadamente constante y conserva el hash de versión esperado del pin.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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
- Lenguaje dominante
- Python
- Estrellas
- 59
- Forks
- 11
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de rstudio/pins-python
-
.maint
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
rstudio/pins-python#280 ·
-
Test board github with a tokenAbiertotesting
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
rstudio/pins-python#196 ·
-
.enhancement
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
rstudio/pins-python#363 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 55/100
rstudio/pins-python#354 ·
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 55/100
rstudio/pins-python#352 ·
Todos los issues de rstudio/pins-python
Issues similares
-
docs(contributing): the two things that silently block a PRPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abiertoavailable documentation good first issue
Dificultad 1/5 1-3 horas Aptitud para principiantes 95/100
Nixitov/Riptide-Native#944 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
JTHCode/secretguard#24 ·
Los mantenedores suelen responder en 1 día
-
area: middleware documentation good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
-
enhancement good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
Los mantenedores suelen responder en 1 día
-
good first issue
Dificultad 1/5 Menos de una hora Aptitud para principiantes 95/100
omarelshamy25x/shamy-hijri#63 ·
Los mantenedores suelen responder en 1 día