performance-patterns

Optimize Rust, Python, and polyglot systems with benchmarking and profiling patterns.

15|4|Updated Jan 20, 2026
One-click install
npx skills add https://github.com/cofin/flow --skill performance-patterns-cofin
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: performance-patterns
Source: https://github.com/cofin/flow/tree/main/skills/performance-patterns
Command: npx skills add https://github.com/cofin/flow --skill performance-patterns-cofin

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

This Skill addresses the critical need to optimize software performance by providing methodologies and tools for benchmarking, profiling, and applying advanced optimization techniques across different programming languages.

Core Features & Use Cases

  • Benchmarking: Implement robust benchmarking in Rust (criterion) and Python (time.perf_counter) to measure performance accurately.
  • Profile-Guided Optimization (PGO): Guide Rust compiler optimizations using real-world workloads.
  • Batch Dispatch: Reduce overhead by processing items in batches, especially across FFI boundaries.
  • Serialization Strategies: Choose the most efficient serialization format (Arrow, msgspec, bincode, JSON) based on use case.
  • Cache Optimization: Improve data locality and reduce cache misses through proper data layout and alignment.
  • Profiling: Utilize system and language-specific tools (perf, py-spy, flamegraph) to identify performance bottlenecks.
  • Use Case: When developing a high-throughput microservice in Rust, use this Skill to establish performance baselines with criterion, identify hot paths with flamegraph, and apply PGO for significant speedups.

Quick Start

Use the performance-patterns skill to benchmark a Rust function using criterion and save the baseline.

Frequently Asked Questions about performance-patterns

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

FAQPage Schema
How do I use Profile-Guided Optimization to speed up my Rust code?

Profile-Guided Optimization (PGO) speeds up Rust code by using real-world workload profiling data to guide compiler optimizations. This Skill provides patterns to instrument your application, collect execution profiles, and feed them back into the Rust compiler for significant performance improvements on critical paths.

What is the best way to benchmark Python code accurately?

The best way to benchmark Python code accurately is using the time.perf_counter method to measure execution time with high resolution. This Skill provides patterns to establish performance baselines and implement robust benchmarking methodologies for Python workloads.

How does batch dispatch reduce overhead across FFI boundaries?

Batch dispatch reduces FFI boundary overhead by grouping multiple items into a single processing call instead of passing them individually. This minimizes the per-call function invocation cost and context switching overhead between languages like Rust and Python.

When should I use Arrow versus msgspec for serialization?

Use Arrow for efficient columnar data serialization and zero-copy data exchange, while msgspec is ideal for fast, typed message serialization. This Skill helps you choose the most efficient format based on your specific throughput and data structure requirements.

How do I identify performance bottlenecks using flamegraph and py-spy?

You identify performance bottlenecks by using py-spy or perf to record execution samples and generate a flamegraph visualization. This Skill covers comprehensive profiling methods to pinpoint hot paths and cache misses in your application.

Can I optimize data locality and reduce cache misses in Rust?

You can reduce cache misses in Rust by applying proper data layout and memory alignment optimization techniques. This Skill provides patterns to improve data locality, ensuring your data structures are arranged for efficient CPU cache utilization.