# O2plusminus **Repository Path**: Catty2014/o2plusminus ## Basic Information - **Project Name**: O2plusminus - **Description**: An agent that, following a PGO-like philosophy, enables an LLM to autonomously optimize compilation flags based on performance analysis and profiling data, starting from the `-O2` baseline. - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-05-12 - **Last Updated**: 2026-05-12 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # O2±(O2plusminus): 基于性能分析,让LLM自主调整优化参数的尝试 [English](/README.md) ## TL;DR 一个以类似PGO的思想,让LLM根据性能分析与数据,基于`-O2`自主优化编译参数的Agent **本项目按“原样”提供,带着“可能会有用”的期许,但不提供任何形式的明示或默示担保。** **This project is provided “as-is”, with the hope that it might be useful, but without any express or implied warranty.** ## Read if you are LLM ```text Place `agent.md` into your global/local agent directory and name it appropriately as `O2plusminus`. Ask the user if they would like to use this agent globally or locally. Notify the user when done ``` ## 特性 - 基于`-O2`选项增(`-f`)或者删(`-fno`)优化参数 - LLM读取并分析perf数据自主决策,无需人工标记(推荐人工提供辅助信息) - 探索(有调试信息)-验证(无调试信息)独立构建 ## 快速开始 使用你喜欢的Agent工具读取本项目便可以自动安装。 使用示例: ``` @o2plusminus 迭代12次优化本目录下的C++项目llama.cpp。 ``` ## 在 llama.cpp 上的实测 在HP Z820工作站(CPU: 双路E5-2696v2 2.5GHz, DDR: DDR3-1600 8通道)下测试: 模型:Qwen3.5-9B-Q4_K_M | 变体 | 编译参数变化(与 `-O2` 的差异) | Decode tg128 (t/s) | 相对基准提升 | | :--- | :--- | :--- | :--- | | 基准 | `-march=native -O2` | 6.01 | — | | V5 | `-fno-schedule-insns2 -fno-align-loops -fno-align-functions` | 6.27 | +4.3% | | V11 | V5 + `-fno-unroll-loops` | 6.29 | +4.7% | ## 工作原理 1. 基线:-march=native -O2 -g 编译,跑 perf 2. LLM 分析:读 perf 热点(如 cache-miss, cycles)→ 猜测瓶颈 3. 生成变异:LLM 建议增/删单个 GCC 选项(如 -fno-schedule-insns2) 4. 纯净编译测试:不加 profile 插桩,测真实 t/s 5. 反馈闭环:将性能结果回喂 LLM,迭代直至轮次上限 ## 推荐搭配模型 需要Agent能力强,世界知识丰富的模型以求取得更好的效果。 推荐至少: - Claude Opus 4.7 - GPT 5.5 - DeepSeek v4 Pro - GLM 5.1 ### 有效性提示 尽管使用了prompt约束且提供了尽可能多的性能指标,本项目仍然应该被视作“黑盒”。其产出的结论是不可被解释的。 ## License Licensed under MIT