You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
server: /load with backend=polars reads the whole file into memory, once per session #993
/load with backend: "polars" reads the whole file into memory with pl.read_parquet (buckaroo/server/data_loading_polars.py:77), and each session holds its own copy. Two sessions on the same path hold two copies.
Measured on a 1.2M-row, 4-column, 11.5 MB parquet: the server's RSS rose by 151 MB on the first /load, and by another 63 MB when a second session loaded the same file. Once warm, repeat POSTs to the same session add about 4 MB each rather than a frame's worth, so the previous frame is released; the cost is per session.
/load_expr reads through DataFusion one window at a time and holds no table.
Impact
tallyman's largest entry is 78,024,179 rows by 43 columns, 3.7 GB of parquet. Through /load each open grid on it would hold that whole table in the buckaroo process, once per session. That rules out moving tallyman's grid from /load_expr to /load for its larger entries.
Suggested fix
Open the file with pl.scan_parquet and apply search, sort and slice to the LazyFrame per window, collecting only the window. The mode: "lazy" path (handle_infinite_request_lazy) already pages a LazyFrame, but without the buckaroo dataflow.
Compute stats with one lazy collect over the scan.
Failing that, share one frame per path across sessions, so the cost is per file instead of per grid.
#769 (lazy polars pipeline, one collect per run) may cover part of this.
Context
Found while checking whether tallyman's grid can move from /load_expr to /load with backend: "polars", on buckaroo 0.15.8 (same code on main at 992fdb3).
Measured on a 10.8M-row × 43-column parquet (28 String columns, 409 MB), PolarsServerSampling.pre_limit = False, one run each:
step
time
memory
pl.read_parquet
0.56 s
estimated_size 2.63 GB, max RSS 6.4 GB
search "NY" (9.5M matches), one window
1.46 s / 0.90 s
search with 0 matches, one window
0.42 s / 0.26 s
sort on a String column, one window
4.47 s
max RSS 17.8 GB
The first figure in each search row is the window at row 0 and the second the window at row 5,000. Every window request repeats the filter, and with a sort, with_row_index().sort(...) (data_loading_polars.py:138) sorts the whole filtered frame again for each window. Keeping the sorted order (or its arg_sort indices) per search and sort would remove the per-window sort.
Scaling linearly by rows, the 78,024,179-row entry would need about 46 GB of RSS just to hold the frame, on a 48 GB machine.
Stats don't need the frame in memory. One select over pl.scan_parquet with the streaming engine computes length, null count, exact distinct, empty count and min/max/mean/std for all 43 columns of the 78M-row file in 4.4 s, with a peak RSS of 13.7 GB (#999).
Activity
paddymul commentedon Oct 2, 2026
Measured on a 10.8M-row × 43-column parquet (28 String columns, 409 MB),
PolarsServerSampling.pre_limit = False, one run each:pl.read_parquetestimated_size2.63 GB, max RSS 6.4 GBThe first figure in each search row is the window at row 0 and the second the window at row 5,000. Every window request repeats the filter, and with a sort,
with_row_index().sort(...)(data_loading_polars.py:138) sorts the whole filtered frame again for each window. Keeping the sorted order (or itsarg_sortindices) per search and sort would remove the per-window sort.Scaling linearly by rows, the 78,024,179-row entry would need about 46 GB of RSS just to hold the frame, on a 48 GB machine.
Stats don't need the frame in memory. One
selectoverpl.scan_parquetwith the streaming engine computes length, null count, exact distinct, empty count and min/max/mean/std for all 43 columns of the 78M-row file in 4.4 s, with a peak RSS of 13.7 GB (#999).perf(server): share one /load frame per file across sessions (#993)
perf(server): cache the filtered and sorted row order per dataflow in…
test(server): switching a session to lazy mode must free its eager fr…
fix(server): drop session.df and dataflow when a session switches to …
perf(server): hold a LazyFrame for backend=polars /load sessions (#993)
test(server): failing tests for lazy polars stats sampling and load e…
perf(server): bound the lazy /load session's stats and sort memory (#993
fix(server): return JSON load_error when a lazy polars load fails lat…