EffiSkill: Agent Skill Based Automated Code Efficiency Optimization

Zimu Wang, Yuling Shi, Mengfan Li, Zijun Liu, Jie M. Zhang, Chengcheng Wan, Xiaodong GuarXiv 2026

TL;DR

EffiSkill introduces a novel framework for code-efficiency optimization by distilling recurring "slow-to-fast" code transformations into a reusable library of agent skills. Unlike traditional approaches that rely on one-shot rewriting or expensive runtime execution feedback, EffiSkill operates entirely execution-free during inference, outperforming state-of-the-art baselines by up to 12.5 percentage points.

What Problem Does This Paper Address?

Large Language Models (LLMs) have shown immense promise in generating and repairing code, but optimizing code for computational efficiency remains a stubborn bottleneck. Current LLM-based optimization methods typically treat every problem as an isolated instance. They either attempt to rewrite code in a single shot, retrieve superficially similar code examples, or use brute-force evolutionary searches that require executing code candidates repeatedly to see what works.

This instance-centric approach misses a fundamental truth: performance-improving edits often share underlying, recurring patterns (e.g., replacing a brute-force loop with a closed-form algebraic equation, or compressing dynamic programming states). Furthermore, relying on live execution feedback is impractical in many real-world software engineering environments due to sandbox constraints, security risks, or compute budgets. EffiSkill bridges this gap by explicitly mining and reusing abstract optimization knowledge without needing runtime execution feedback.

Figure 1: Overview of agent skills as reusable knowledge.

Methods

EffiSkill decouples the learning of optimization knowledge from its application using a two-stage paradigm:

Overview of EffiSkill workflow

Stage I: Offline Skill Mining

The framework automatically analyzes a corpus of paired slow and fast programs to extract reusable optimization principles.

  1. Trace Extraction & Abstraction: An LLM generates a structured "optimization trace" for each pair, detailing the bottleneck in the slow code and the core optimization idea in the fast code. This trace is abstracted into a compact signature (e.g., complexity shift, trigger conditions).
  2. Hybrid Clustering: Signatures are clustered in a hybrid lexical-semantic space using TF-IDF and dense sentence embeddings to group similar optimization mechanisms together, even if their surface wording differs.
  3. Skill Card Distillation: Each cluster is distilled into a structured Operator Skill (encoding concrete mechanisms like "full DP -> rolling state") or a Meta Skill (higher-level control logic for orchestrating operators).
Figure 2: Structure of the two skill-card artifacts in EffiSkill.

Stage II: Skill-Guided Optimization (Inference)

When given a new, unoptimized program, EffiSkill optimizes it without running the code:

  • Diagnosis: It generates an optimization brief identifying potential bottlenecks.
  • Retrieval: It retrieves relevant Operator Skills from the mined library.
  • Plan Composition: Meta Skills act as procedural controllers to compose these operators into 2–3 distinct optimization plans.
  • Candidate Generation: The LLM generates optimized code candidates based on these structured plans.

Datasets

  • Skill-Mining Corpus: The offline library was built using 900 Python pairs and 900 C++ pairs curated from competitive programming datasets, including PIE, Mercury, DeepMind Code Contests, and CodeParrot APPS. A speedup ratio of at least $2\times$ was required for inclusion.
  • Evaluation Benchmark: The framework was evaluated on EffiBench-X, a benchmark containing 623 optimization tasks with expert-written canonical solutions. The authors focused on the Python and C++ subsets, ensuring zero overlap with the mining corpus.

Key Insights and Ideas

  • Mechanism-Level vs. Instance-Level Reuse: Instead of asking an LLM to copy a specific code example, EffiSkill forces it to apply an abstract concept (an "Operator Skill"). This allows the model to generalize across programs that look completely different syntactically but share the same algorithmic bottleneck.
  • The Power of Structured Priors: Conditioning code generation on a retrieved skill card acts as a regularizer. It prevents the LLM from simply cleaning up variable names or making minor syntax tweaks, guiding it instead toward high-impact algorithmic reformulations.
  • Compositionality Matters: Many complex optimization tasks cannot be solved with a single trick. EffiSkill’s pipeline allows the model to combine multiple skills (e.g., combining constant-factor cleanup with cheaper arithmetic) into a single, cohesive plan.

Key Results

The authors evaluated EffiSkill using two LLM backbones: GPT-5-mini and Qwen3-Coder-30B-A3B-Instruct. Performance was measured using OPT@k, the percentage of tasks where at least one of the top-$k$ generated candidates was functionally correct and achieved at least a 10% runtime reduction.

  • Overall Performance: EffiSkill consistently achieved the highest optimization success rates across all settings, outperforming strong baselines like RAG, Chain-of-Thought (CoT), and search-based methods (SBLLM).
  • GPT-5-mini Results: On Python, EffiSkill achieved an OPT@8 of 37.40% (improving over the best baseline's 32.42%). On C++, it achieved an OPT@8 of 66.77% (compared to the best baseline's 54.74%).
  • Qwen3-Coder Results: EffiSkill achieved a 36.60% OPT@8 on Python and 56.50% OPT@8 on C++, outperforming the specialized fine-tuned baseline, EffiCoder.
  • Ablation Studies: Removing the skill retrieval step caused performance to plummet (e.g., Qwen3's OPT@8 dropped from 36.60% to 9.15%), proving that explicit skill guidance is the primary driver of EffiSkill's success.

Limitations and Future Work

While highly effective, the authors note several limitations:

  • Domain Specificity: The framework was trained and tested on competitive programming benchmarks. Real-world enterprise software involves massive codebases, external library dependencies, and complex hardware interactions that aren't captured here.
  • Pipeline Dependencies: The quality of the skill library heavily depends on the initial LLM-generated traces and the chosen clustering hyperparameters.
  • Metric Narrowness: The evaluation strictly optimizes for execution speed and correctness, ignoring other vital software qualities like code readability and maintainability.

Future Directions: The team aims to extend EffiSkill to more programming languages, integrate it into broader agentic workflows as a plug-and-play toolbox, and explore how to mine more novel or complex optimization strategies.

Summary updated

BibTeX
@misc{wang2026effiskill,
  author = {Zimu Wang and Yuling Shi and Mengfan Li and Zijun Liu and Jie M. Zhang and Chengcheng Wan and Xiaodong Gu},
  title = {{EffiSkill: Agent Skill Based Automated Code Efficiency Optimization}},
  year = {2026},
  eprint = {2603.27850},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2603.27850},
}
Figure