Communitygithub.com

バッチ処理オプティマイザー

Spark、Polars、DuckDB、pandasを使用したバッチデータ処理のメモリ効率、並列性、コスト削減を最適化します。

バッチ処理オプティマイザー とは?

このスキルは、開発者やAIエージェントがバッチデータ処理のワークロードを効率的に最適化するための包括的なガイドです。Apache Spark、Polars、DuckDB、pandasといった主要なデータフレーム技術を対象とし、データサイズや処理の複雑さに応じた最適なツール選択の基準を提供します。Sparkの適応型クエリ実行(AQE)やPolarsの遅延評価など、各プラットフォーム固有の最適化パターンやアンチパターン(大規模データでのcollect()の回避、パーティションスキューへの対処など)を具体的なコード例とともに解説します。また、ブロードキャスト結合、カラムプルーニング、パーティション分割といった実践的なテクニックを多数含み、DatabricksやEMRなどのクラウド環境にも対応。品質チェックリストを使って効果を確認しながら、コストとパフォーマンスのバランスを最適化できます。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/curiositech/windags-skills/tree/HEAD/skills/batch-processing-optimizer

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

バッチ処理オプティマイザー は何をしますか?

Spark、Polars、DuckDB、pandasを使用したバッチデータ処理のワークロードを、メモリ効率・並列性・コスト削減に焦点を当てて最適化します。

起動トリガー

アクティブ化条件: 「バッチ処理」「Spark最適化」「Polars」「DuckDB」「pandasパフォーマンス」「データフレーム」「シャッフル最適化」「パーティションスキュー」「メモリ最適化」「メモリ不足」

対象外: リアルタイムストリーミング → streaming-pipeline-architect | ウェアハウスSQLチューニング → data-warehouse-optimizer | パイプラインオーケストレーション → airflow-dag-orchestrator

クイックスタート

  1. 適切なツールを選ぶ — 単一ノード分析にはDuckDB、DataFrameにはPolars、分散処理にはSpark
  2. まずプロファイリング — 最適化前にボトルネック(シャッフル、スキュー、メモリ)を特定する
  3. 早期にデータを削減 — パイプラインのできるだけ早い段階でフィルタリングとカラム選択を行う
  4. シャッフルを避ける — 小さなテーブルはブロードキャストし、データを事前パーティション化、マップサイド結合を使用する
  5. 適切なリソースサイズ — エグゼキュータのメモリ/コアを実際のデータサイズに合わせる

コア機能

ドメインテクノロジー
分散処理Apache Spark 3.5+, Dask, Ray
単一ノードDuckDB 1.1+, Polars 1.x, pandas 2.2+
ファイル形式Parquet, Arrow IPC, Delta Lake, Iceberg
最適化AQE (Spark), 遅延評価 (Polars), カラムナー型スキャン
クラウドDatabricks, EMR, Dataproc, サーバーレスSpark

アーキテクチャパターン

ツール選択の決定木

データサイズ?
  ├─ < 10 GB     → DuckDB (SQL) または Polars (DataFrame)
  │                 単一マシン、ゼロセットアップ、最速のイテレーション
  │
  ├─ 10-100 GB   → Polars (遅延) または DuckDB (アウトオブコア)
  │                 依然として単一マシン、ディスクへのスピルが可能
  │
  └─ > 100 GB    → Spark (分散処理)
                    マルチノードクラスター、シャッフルベースの結合

複雑さ?
  ├─ SQL中心     → DuckDB (分析向け最速のSQLエンジン)
  ├─ DataFrame    → Polars (pandasより10倍高速、遅延評価)
  └─ 複雑なML    → Spark + MLlib または Spark + Ray

Spark最適化パターン

from pyspark.sql import SparkSession
import pyspark.sql.functions as F

spark = SparkSession.builder \
    .config("spark.sql.adaptive.enabled", "true") \
    .config("spark.sql.adaptive.coalescePartitions.enabled", "true") \
    .config("spark.sql.adaptive.skewJoin.enabled", "true") \
    .getOrCreate()

# 良い例: 小さなディメンションテーブル(< 100MB)をブロードキャスト
from pyspark.sql.functions import broadcast
result = large_df.join(broadcast(small_dim_df), "key")

# 良い例: 述語プッシュダウン — 結合前にフィルタリング
orders = spark.read.parquet("s3://data/orders/") \
    .filter(F.col("order_date") >= "2026-01-01") \
    .select("order_id", "customer_id", "amount")  # カラムプルーニング

# 悪い例: 大規模データセットでのcollect() — ドライバーでOOMを引き起こす
# all_data = large_df.collect()  # 絶対にやらない

# 良い例: パーティション化された出力を書き込む
result.repartition(200) \
    .write.mode("overwrite") \
    .partitionBy("order_date") \
    .parquet("s3://output/results/")

Polars遅延評価

import polars as pl

# 遅延モード: クエリプランを構築し、最適化してから実行
result = (
    pl.scan_parquet("data/orders/*.parquet")  # 遅延スキャン
    .filter(pl.col("order_date") >= "2026-01-01")
    .join(
        pl.scan_parquet("data/customers/*.parquet"),
        on="customer_id",
        how="inner"
    )
    .group_by("region")
    .agg([
        pl.col("amount").sum().alias("total_revenue"),
        pl.col("order_id").n_unique().alias("order_count"),
    ])
    .sort("total_revenue", descending=True)
    .collect()  # 最適化されたプランを実行
)

# Polarsは自動的に: 述語プッシュダウン、射影プッシュダウン、
# 結合の並べ替えを遅延評価で最適化

アンチパターン

  1. 5GB超でのpandas — pandasは全データをメモリに読み込む; 中規模データにはPolars(遅延)またはDuckDBを、大規模データにはSparkを使用する
  2. ドライバーへのcollect — 大規模なSpark DataFrameでのdf.collect()やdf.toPandas()はOOMを引き起こす; 事前に集約する
  3. パーティションスキューの無視 — 一つのパーティションに他の10倍のデータがあるとジョブ全体がボトルネックになる; AQEまたはソルティングを使用する
  4. 全カラムの読み取り — 必要なカラムのみを常に選択する; Parquetのカラムナー形式は未使用のカラムを完全にスキップする
  5. 小さすぎる出力ファイル — 小さな出力ファイル(< 128MB)が多すぎると後続の読み取りが遅くなる; 書き込み前にcoalesceする

品質チェックリスト

  • ツールがデータサイズに一致している(DuckDB/Polars < 100GB, Spark > 100GB)
  • カラムが早期にプルーニングされている(必要なものだけを選択)
  • フィルタがスキャンレベルでプッシュダウンされている(述語プッシュダウン)
  • 小さなテーブルが結合時にブロードキャストされている(< 100MB)
  • Spark AQEが有効(適応型クエリ実行)
  • 大規模データセットでcollect()を使用していない(事前に集約してから収集)
  • 出力ファイルのサイズが128MB〜1GBに設定されている(書き込み前にcoalesce/repartition)
  • パーティションスキューが監視・緩和されている(ソルティングまたはAQE)
  • ジョブがプロファイリングされている: Spark UIのステージ、Polarsの.explain()、DuckDBのEXPLAIN ANALYZE
  • メモリが適切に設定されている: エグゼキュータメモリ >= 最大パーティションサイズの2倍

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

curiositech/windags-skills

Expert in 2000s-era music visualization (Milkdrop, AVS, Geiss) and modern WebGL implementations. Specializes in Butterchurn integration, Web Audio API AnalyserNode FFT data, GLSL shaders for audio-reactive visuals, and psychedelic generative art. Activate on "Milkdrop", "music visualization", "WebGL visualizer", "Butterchurn", "audio reactive", "FFT visualization", "spectrum analyzer". NOT for simple bar charts/waveforms (use basic canvas), video editing, or non-audio visuals.

curiositech/windags-skills

Expert legal research agent for finding and scraping expungement data state by state. Knows authoritative sources, URL patterns, Firecrawl configuration, and 2026 legal landscape.

curiositech/windags-skills

Expert in 3D computer vision labeling tools, workflows, and AI-assisted annotation for LiDAR, point clouds, and sensor fusion. Covers SAM4D/Point-SAM, human-in-the-loop architectures, and vertical-specific training strategies. Activate on '3D labeling', 'point cloud annotation', 'LiDAR labeling', 'SAM 3D', 'SAM4D', 'sensor fusion annotation', '3D bounding box', 'semantic segmentation point cloud'. NOT for 2D image labeling (use clip-aware-embeddings), general ML training (use ml-engineer), video annotation without 3D (use computer-vision-pipeline), or VLM prompt engineering (use prompt-engineer).

curiositech/windags-skills

Implement WCAG 2.2 AA/AAA compliance with automated testing, keyboard navigation, screen reader support, and focus management. Activate on: accessibility audit, WCAG compliance, keyboard navigation, screen reader, aria attributes, axe-core, focus trap. NOT for: design-level accessibility review (use design-accessibility-auditor), color contrast only (use css-in-js-architect).

curiositech/windags-skills

Time-blind friendly planning, executive function support, and daily structure for ADHD brains. Specializes in realistic time estimation, dopamine-aware task design, and building systems that actually work for neurodivergent minds.

curiositech/windags-skills

Designs digital experiences for ADHD brains using neuroscience research and UX principles. Expert in reducing cognitive load, time blindness solutions, dopamine-driven engagement, and compassionate design patterns. Activate on 'ADHD design', 'cognitive load', 'accessibility', 'neurodivergent UX', 'time blindness', 'dopamine-driven', 'executive function'. NOT for general accessibility (WCAG only), neurotypical UX design, or simple UI styling without ADHD context.

curiositech/windags-skills

>- Apply crisis decision-making research to agent routing, uncertainty triage, and coordination failure analysis in time-pressured systems. Use when diagnosing handoff failures, analytical paralysis, or expert judgment under incomplete information. NOT for routine coding, simple CRUD design, or static single-agent tasks with complete information.

curiositech/windags-skills

Extend and modify the admin dashboard, developer portal, and operations console. Use when adding new admin tabs, metrics, monitoring features, or internal tools. Activates for dashboard development, analytics, user management, and internal tooling.

curiositech/windags-skills

Conversation patterns and interaction protocols for multi-agent systems. Covers request/response, pub/sub, blackboard, delegation chains, debate, critique, consensus, fan-out/fan-in, supervisor-worker, and peer negotiation. Deep analysis of AutoGen conversation patterns, CrewAI delegation, LangGraph state passing, and FIPA-ACL performatives. Teaches how to design what agents say to each other and in what order. Activate on: "agent conversation", "agent protocol", "multi-agent debate", "agent delegation", "supervisor worker pattern", "agent voting", "consensus protocol", "fan-out fan-in", "agent negotiation", "blackboard pattern", "agent dialogue", "conversation topology", "agent handoff". NOT for: wire format or serialization (use agent-interchange-formats), orchestration infrastructure (use agentic-infrastructure-2026), single agent behavior (use agentic-patterns).

curiositech/windags-skills

Meta-agent for creating new custom agents, skills, and MCP integrations. Expert in agent design, MCP development, skill architecture, and rapid prototyping. Activate on 'create agent', 'new skill', 'MCP server', 'custom tool', 'agent design'. NOT for using existing agents (invoke them directly), general coding (use language-specific skills), or infrastructure setup (use deployment-engineer).

curiositech/windags-skills

AI-powered calendar management and agent-based scheduling coordination. Covers calendar APIs (Google Calendar, CalDAV/iCal), AI scheduling assistants (Reclaim, Clockwise, Motion, Cal.com), building custom calendar agents with MCP, multi-calendar merging, timezone management, focus block protection, meeting fatigue detection, and agent-to-agent meeting negotiation protocols. Activate on: "calendar agent", "AI scheduling", "calendar coordination", "meeting scheduling", "calendar API", "focus time protection", "calendar optimization", "Google Calendar MCP", "Reclaim", "Clockwise", "Motion", "Cal.com", "smart scheduling", "calendar-aware agent", "timezone scheduling", "agent negotiation meetings". NOT for: manual calendar UI component design (use form-validation-architect), project management scheduling or Gantt charts (use project-management-guru-adhd), general time-tracking or pomodoro apps (use adhd-daily-planner for time-awareness), building the agent itself from scratch (use agent-creator).

curiositech/windags-skills

Build and adopt production AI agent infrastructure in 2026. Covers framework selection (LangGraph, CrewAI, AutoGen, MCP), orchestration patterns, evaluation, observability, memory systems, and tool use. Also covers the SOCIAL dimension: how to sell agent infrastructure internally, change management, measuring ROI, building trust in autonomous systems, and scaling adoption across teams. Activate on: "agent infrastructure", "agent framework comparison", "which agent framework", "sell AI tools internally", "agent adoption", "agent observability", "agent evaluation", "MCP architecture", "agentic mesh", "enterprise AI agents", "AI change management", "agent ROI". NOT for: building specific agents (use ai-engineer), designing agent behavior patterns (use agentic-patterns), prompt tuning (use prompt-engineer).

curiositech/windags-skills

Fundamental patterns for effective agentic behavior. Teaches decomposition, tool orchestration, error recovery, context management, quality self-assessment, and knowing when to stop. Model-agnostic principles that make any agent more effective regardless of domain. Activate on: "how should I structure this agent", "agentic workflow", "agent patterns", "multi-step task", "tool orchestration", "/agentic-patterns", "decompose this", "agent best practices", "chain of actions", "when should the agent stop", "agent loop design". NOT for: creating agent infrastructure (use agent-creator), building DAGs (use windags-architect), specific tool implementation.

curiositech/windags-skills

Automated discovery and matching of agent skills for dynamic task routing and capability assessment

curiositech/windags-skills

Cryptographic security for agentic systems — zero-trust agent networking, signed message envelopes (JWS/JWE), capability-based security (ocaps), Merkle tree audit trails, WASM sandboxing, and formal verification. Covers CLI dev tool security, mTLS between agents, permission boundaries (least privilege for AI agents), and supply chain security for skills/plugins. Activate on: "agent security", "zero trust agents", "secure agent communication", "capability-based security", "ocap", "signed messages between agents", "agent audit trail", "sandbox agent execution", "agent permissions", "mTLS agents", "cryptographic verification", "agent supply chain", "OWASP agentic", "prove agent did X", "tamper-proof agent logs". NOT for: application-level SAST scanning (use security-auditor), network firewall rules (use infrastructure), SOC2/HIPAA compliance (organizational), or prompt injection defense (use prompt-engineer).

curiositech/windags-skills

Data structures and serialization formats for agent-to-agent communication. Covers message envelopes, structured output schemas, capability declarations, task handoff payloads, error/retry signaling, and context windows as data structures. Deep comparison of A2A protocol, MCP, OpenAI function calling, and LangChain message types. Teaches when to use rigid schemas vs free-form with validation, typed vs untyped, streaming vs batch. Activate on: "agent message format", "agent communication schema", "agent-to-agent protocol", "A2A protocol", "MCP message format", "structured output for agents", "agent interop", "interchange format", "agent serialization", "task handoff format", "capability declaration". NOT for: what agents say to each other (use agent-conversation-protocols), orchestration topology (use multi-agent-coordination), building agent infrastructure (use agentic-infrastructure-2026).

curiositech/windags-skills

Logic-based agent programming language implementing BDI architecture for practical autonomous agent development

curiositech/windags-skills

>- Design AgentSpeak(L)-style BDI agents with context-guarded plans, selection functions, and intention stacks. Use for interruptible autonomy, agent policy, and multi-agent orchestration in dynamic environments. NOT for simple rule engines, static planners, or centralized workflows.

curiositech/windags-skills

Foundational concurrent computation model where actors communicate exclusively through asynchronous message passing

curiositech/windags-skills

license: Apache-2.0 NOT for unrelated tasks outside this domain.

関連スキル