polars stats: value_counts and mode run as two group-bys per column, one column at a time
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 48/100
- issue の種類
- リファクタリング
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- python
- 領域
- data, performance
調査の方向性
Start with buckaroo/customizations/pl_stats_v2.py and buckaroo/pluggable_analysis_framework/df_stats_v2.py, then trace how StatPipeline passes each stat a pl.Series. First verify that taking mode from the existing value-counts result preserves behavior, including tied values; then investigate batching the per-column group-bys with pl.collect_all or a single select. Done means the redundant mode group-by is removed and batched results are handed to each stat correctly, with the reported performance improvement checked against equivalent stats.
索引モデルが issue の本文から書いたものです。
説明
Problem
With the 50,000-row sample in PlDfStatsV2.get_operating_df (buckaroo/pluggable_analysis_framework/df_stats_v2.py:93) bypassed, PlDfStatsV2 takes 12.4 s on a 10,803,012-row, 43-column parquet (28 String columns). Most of that is two group-bys per column in pl_base_summary_stats (buckaroo/customizations/pl_stats_v2.py:77), run one column at a time:
_pl_vc_to_pdcallsser.drop_nulls().value_counts(sort=True)(pl_stats_v2.py:69): 6.8 s over the 43 columns. The sort isn't the cost (sort=Falseis 6.4 s), and the conversion to a pandas Series is 0.14 s in total. The widest column, 3,059,039 distinct strings, takes 1.6 s on its own.ser.drop_nulls().mode().item(0)(pl_stats_v2.py:86): 2.5 s. It is a second group-by on the same column, and its answer is the first row of thevalue_countscomputed just before it.
StatPipeline hands each stat one pl.Series at a time, so polars never runs these across columns in parallel. The same 43 value_counts collected together with pl.collect_all over one lazy select per column take 2.8 s instead of 6.9 s.
Impact
This is the cost of exact stats on the polars path. On the same file, XorqServerDataflow over deferred_read_parquet computes its stats in 3.4 s. It matters for /load with backend: "polars" once #992 stops sampling the frame: today stats on large frames come from the 50,000-row sample, so distinct_count on a column of unique IDs reads 50,000.
Suggested fix
- Take
modefrom the first row of thevalue_countsthatpl_base_summary_statsalready computes, instead of callingmode(). Saves about 2.5 s here. Both leave the choice among tied values unspecified today. - Compute the per-column group-bys for all columns in one parallel collect (
pl.collect_all, or a singleselect) and hand each stat its column's result. This needs the polars stat pipeline to batch across columns, so it is the larger change.
Context
Found while measuring /load with backend: "polars" for tallyman (#992, #993). Measured on main at 992fdb3 with polars 1.35.2 on an Apple M4 Pro (14 cores), frame already in memory before timing.
- 主要言語
- Python
- スター
- 685
- フォーク
- 17
- 平均マージ
- 1日 4時間
- マージ済み PR(30日)
- 29
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
buckaroo-data/buckaroo のほかの issue
-
Histograms JS
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
buckaroo-data/buckaroo#1089 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Histograms
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
buckaroo-data/buckaroo#1087 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Histograms
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
buckaroo-data/buckaroo#1086 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Histograms
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
buckaroo-data/buckaroo#1083 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Histograms
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
buckaroo-data/buckaroo#1082 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
buckaroo-data/buckaroo の issue をすべて見る
似ている issue
-
enhancement good first issue Stellar Wave trivial
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
StellarCanary/ProtocolCanary-Fixtures#258 ·
メンテナーはふだん 1 日以内に返信
-
github_actions
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
Hochfrequenz/aibap.mcp#578 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
mishraprafful/multihull#150 ·
メンテナーはふだん 1 日以内に返信
-
mp: /status reports the server class name as engine_type, not the configured engine対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
python-caldav/caldav#735 ·
メンテナーはふだん 1 日以内に返信