Repository navigation
Conversation
…sample (#992) PolarsServerSampling.pre_limit = 1_000_000 makes pre_stats_sample hand CustomizableDataflow a shuffled df.sample(1_000_000) as its raw frame, so a file with more rows pages a random sample out of file order. Covers create_polars_dataflow directly (row count and the first window's order) and POST /load with backend=polars on a 1.2M-row parquet (df_meta filtered_rows must equal total_rows). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
📦 TestPyPI package publishedpip install --index-strategy unsafe-best-match --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ buckaroo==0.15.9.dev37080672845or with uv: uv pip install --index-strategy unsafe-best-match --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ buckaroo==0.15.9.dev37080672845MCP server for Claude Codeclaude mcp add buckaroo-table -- uvx --from "buckaroo[mcp]==0.15.9.dev37080672845" --index-strategy unsafe-best-match --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ buckaroo-table📖 Docs preview🎨 Storybook preview |
PolarsServerSampling.pre_limit = 1_000_000 made pre_stats_sample hand CustomizableDataflow a shuffled df.sample(1_000_000) as its raw frame, so a file with more rows paged a random sample out of file order, and every sort and search ran against it. pre_limit never capped the stats work its docstring described: PlDfStatsV2.get_operating_df already samples 50k rows for the stats pipeline. pre_limit = False, as PLSampling and XorqInfiniteSampling already use, keeps the whole frame in file order. The pandas ServerSampling keeps its pre_limit for now; it sorts the sample, so order survives there, but rows are still dropped. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
MeasurementsI ran the server from this branch (d52ddab) and from main (992fdb3), loading real files with parking_2017.parquet (10,803,012 rows, 43 columns, 409 MB):
Idle server RSS before load is 165 MB in both. 8e98b80a36ef.parquet (52,814 rows, 27 columns). This file is below the old 1M cap, so it is a control and the two builds should match:
What varied with what:
Every run returned no |
|
Closed. sampling for in memory is a valid approach. We need to do out of core, something similar to lazyinfinitepolars to really address this |
Fixes #992.
Problem
/loadwithbackend: "polars"pages a random 1M-row sample, shuffled, when the file has more rows.PolarsServerSampling.pre_limit = 1_000_000(buckaroo/server/data_loading_polars.py) feedsSampling.pre_stats_sample, whichCustomizableDataflow.__init__uses to build the dataflow's raw frame (dataflow.py:420), andpre_stats_samplereturnsdf.sample(pre_limit). The sample becomes the table: every row request, sort and search runs against it, anddf_metareportsfiltered_rows: 1000000againsttotal_rows: 1200000.The class docstring says
pre_limitcaps the stats work. It doesn't.PlDfStatsV2.get_operating_dfalready samples 50k rows (seed 42) for the stats pipeline wheneverrows * colsexceedsFAST_SUMMARY_WHEN_GREATER, independent ofpre_limit.Approach
This is one of several candidate approaches for #992. It sets
pre_limit = FalseonPolarsServerSampling, whichPLSampling(the notebook polars widget) andXorqInfiniteSamplingalready do, so the dataflow's raw frame is the whole file in file order. Stats keep their existing 50k-row sample inPlDfStatsV2.The alternative being tried in parallel keeps a row cap for the stats input but applies it only to what
DFStatsClassreads, marking the stats as sampled, instead of replacingraw_df.What changes
PolarsServerSampling.pre_limitgoes from1_000_000toFalse; the docstring says what the class actually does.ServerSampling(buckaroo/server/data_loading.py) has the samepre_limit = 1_000_000. Itsort_index()es the sample, so rows come back in file order there, but 200k of 1.2M rows are still dropped. That's a separate change.Tests
tests/unit/server/test_data_loading_polars.py::test_dataflow_keeps_every_row_in_file_order:create_polars_dataflowon a 1.2M-row frame keeps all rows and the first window is rows 0..99.tests/unit/server/test_server.py::TestLoad::test_load_polars_backend_keeps_every_row:POST /loadwithbackend=polarson a 1.2M-row parquet answersrows: 1200000and the session'sdf_metahasfiltered_rows == total_rows == 1200000.Trade-offs
A
/loadof a very large parquet now holds the whole frame in memory as the dataflow'sraw_dfandprocessed_df, instead of a 1M-row sample. That's the same memory profile asload_file_polarsalready has (it reads the file eagerly), so the cap only ever saved the dataflow's copy. Sorts and searches over the websocket now run over the full frame; the #999 measurements cover what that costs.🤖 Generated with Claude Code