Communitygithub.com

curiositech/batch-processing-optimizer

批次資料處理工作負載最佳化,使用 Spark、Polars、DuckDB 與 pandas,專注於記憶體效率、平行處理與成本降低。

batch-processing-optimizer 是什麼?

此技能可協助開發者針對批次資料處理管線選擇適當的工具並套用最佳化策略。根據資料量大小(小於 10 GB:DuckDB 或 Polars;10–100 GB:Polars 或 DuckDB 溢寫磁碟;大於 100 GB:Spark 分散式處理)以及查詢複雜度(SQL 為主的分析、DataFrame 操作、複雜機器學習)提供決策樹引導。詳細的程式碼範例涵蓋 Spark AQE、廣播小表格(< 100 MB)、述詞下推、欄位修剪;Polars 惰性評估自動最佳化查詢計畫;以及避免 collect()、處理分割傾斜、控制輸出檔案大小等反模式。支援 Apache Spark 3.5+、Polars 1.x、DuckDB 1.1+、pandas 2.2+,以及 Parquet、Arrow IPC、Delta Lake、Iceberg 等檔案格式。透過 Spark UI 階段、Polars .explain() 或 DuckDB EXPLAIN ANALYZE 進行效能分析,可確保批次處理工作達到高效率、低記憶體使用與成本效益。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/curiositech/windags-skills/tree/HEAD/skills/batch-processing-optimizer

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

批次處理最佳化工具

最佳化使用 Spark、Polars、DuckDB 與 pandas 的批次資料處理工作負載,專注於記憶體效率、平行處理與成本降低。

觸發條件

啟用於:「批次處理」、「Spark 最佳化」、「Polars」、「DuckDB」、「pandas 效能」、「資料幀」、「shuffle 最佳化」、「分割傾斜」、「記憶體最佳化」、「記憶體不足」

**不適用於:**即時串流 → streaming-pipeline-architect | 資料倉儲 SQL 調校 → data-warehouse-optimizer | 管線編排 → airflow-dag-orchestrator

快速入門

  1. 選擇正確的工具 — 單節點分析用 DuckDB,DataFrame 用 Polars,分散式用 Spark
  2. 先剖析 — 最佳化前先找出瓶頸(shuffle、傾斜、記憶體)
  3. 早期縮減資料 — 在管線中盡早進行過濾與欄位選擇
  4. 避免 shuffle — 廣播小表格、預先分區資料、使用 map-side 聯結
  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(分散式)
                    多節點叢集、shuffle 式聯結

複雜度?
  ├─ 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. 收集至驅動程式 — 對大型 Spark DataFrame 使用 df.collect() 或 df.toPandas() 會造成 OOM;請先彙總
  3. 忽略分割傾斜 — 某個分割承載比其它分割多 10 倍的資料,會拖慢整個工作;請使用 AQE 或加鹽(salting)
  4. 讀取所有欄位 — 永遠只選擇需要的欄位;Parquet 欄位格式會完全跳過未使用的欄位
  5. 輸出檔案過小 — 太多小型輸出檔案(< 128MB)會拖慢下游讀取;寫入前請先合併(coalesce)

品質檢查清單

  • 工具與資料大小匹配(DuckDB/Polars < 100GB,Spark > 100GB)
  • 欄位已提前修剪(只選取需要的欄位)
  • 過濾條件已下推至掃描層級(述詞下推)
  • 聯結中小表格已廣播(< 100MB)
  • Spark AQE 已啟用(自適應查詢執行)
  • 未對大型資料集使用 collect()(彙總後再收集)
  • 輸出檔案大小為 128MB–1GB(寫入前已 coalesce/repartition)
  • 分割傾斜已監控並緩解(salting 或 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.

相關技能