pgo

Optimize C/C++ binaries with two-stage PGO builds using GCC and Clang.

159|20|Updated Feb 20, 2026
One-click install
npx skills add https://github.com/mohitmishra786/low-level-dev-skills --skill pgo
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pgo
Source: https://github.com/mohitmishra786/low-level-dev-skills/tree/main/skills/compilers/pgo
Command: npx skills add https://github.com/mohitmishra786/low-level-dev-skills --skill pgo

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill helps you significantly improve the runtime performance of your C/C++ applications by guiding the compiler to make better optimization decisions based on actual program usage.

Core Features & Use Cases

  • Profile-Guided Optimization (PGO): Implement a two-stage build process where the first stage collects runtime profile data, and the second stage uses this data to optimize the binary more effectively than standard compiler flags.
  • GCC & Clang Support: Provides workflows for both major C/C++ compilers.
  • BOLT Integration: Offers post-link optimization using BOLT for further performance gains by reordering code based on profile data.
  • Use Case: You have a critical C++ application that has hit performance plateaus with -O3. Using PGO, you can achieve an additional 5-15% speedup by training the compiler on representative workloads.

Quick Start

Use the pgo skill to build an optimized C++ binary using GCC and profile data.

Frequently Asked Questions about pgo

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I use profile-guided optimization to boost C++ performance beyond -O3?

Profile-guided optimization (PGO) boosts C++ performance by using a two-stage build process where the first stage collects runtime profile data and the second stage uses this data to optimize the binary more effectively than standard compiler flags, achieving an additional 5-15% speedup over -O3.

Does profile-guided optimization work with both GCC and Clang compilers?

Yes, profile-guided optimization works with both GCC and Clang compilers, providing workflows for implementing two-stage PGO builds to guide better optimization decisions based on actual program usage.

What is BOLT post-link optimization and when do I need it for C/C++ binaries?

BOLT post-link optimization is a technique that reorders code based on profile data to achieve further performance gains. You need it when you require maximum runtime performance for large, branch-heavy, or call-intensive C/C++ applications.

How do I collect runtime profile data for a two-stage PGO build?

To collect runtime profile data for a two-stage PGO build, you compile the binary in the first stage with instrumentation, run it using representative workloads to generate usage data, and then use that profile data in the second stage to optimize the final binary.

When should I not use profile-guided optimization for my C++ application?

You should avoid profile-guided optimization if your application's runtime behavior is highly unpredictable or lacks representative workloads, as the collected profile data will not accurately reflect actual usage and may not yield optimal performance gains.