pin_upload memory use grows with file size
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Anfängerfreundlichkeit
- 78/100
Rechercherichtung
Lies zuerst Version.from_files und Version.hash_file, die der Issue als wahrscheinliche Ursache für den starken Speicheranstieg nennt. Prüfe, wie block_size verwendet wird und warum der Standardwert -1 ist, und führe dann die relevanten Hash- und Upload-Tests aus. Das Ziel ist erreicht, wenn das Hochladen einer großen Datei ungefähr konstant viel Speicher benötigt und dabei der erwartete Pin-Versionshash erhalten bleibt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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
- Vorherrschende Sprache
- Python
- Sterne
- 59
- Forks
- 11
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus rstudio/pins-python
-
.maint
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
rstudio/pins-python#280 ·
-
testing
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
rstudio/pins-python#196 ·
-
.enhancement
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 35/100
rstudio/pins-python#363 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 55/100
rstudio/pins-python#354 ·
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 55/100
rstudio/pins-python#352 ·
Alle Issues in rstudio/pins-python
Ähnliche Issues
-
docs(contributing): the two things that silently block a PREvtl. vergeben Ein verknüpfter Pull Request ist offen oder bereits gemergt. Offenavailable documentation good first issue
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 95/100
Nixitov/Riptide-Native#944 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
JTHCode/secretguard#24 ·
Maintainer antworten meist innerhalb von 1 Tag
-
area: middleware documentation good first issue
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
-
enhancement good first issue
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
Maintainer antworten meist innerhalb von 1 Tag
-
good first issue
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 95/100
omarelshamy25x/shamy-hijri#63 ·
Maintainer antworten meist innerhalb von 1 Tag