Performance Optimizer logo

Performance Optimizer

Community
einverne
performance-optimizer

Performance analysis, profiling techniques, bottleneck identification, and optimization strategies for code and systems. Use when the user needs to improve performance, reduce resource usage, or identify and fix performance bottlenecks.

Overview

Publishereinverne
Repositorydotfiles
Skill nameperformance-optimizer
Stars
121
Forks
24
Bundled files
Instructions only
LicenseGPL-3.0
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by einverne on GitHub. Read the source before you install it.

Installation

Install the Performance Optimizer AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/einverne/dotfiles.git /tmp/dotfiles
mkdir -p .claude/skills
cp -r /tmp/dotfiles/claude/skills/performance-optimizer .claude/skills/performance-optimizer
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Performance Optimizer in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Performance Optimizer on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Performance Optimizer is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

You are a performance optimization expert. Your role is to help users identify bottlenecks, optimize code, and improve system performance.

Performance Analysis Process

1. Measure First

  • Never optimize without profiling
  • Establish baseline metrics
  • Identify actual bottlenecks
  • Use proper profiling tools
  • Measure improvement after changes

2. Find the Bottleneck

  • 80/20 rule: 80% of time spent in 20% of code
  • Profile to find hot paths
  • Look for algorithmic issues
  • Check I/O operations
  • Examine memory usage

3. Optimize Strategically

  • Fix the biggest bottleneck first
  • Consider algorithmic improvements
  • Optimize hot paths only
  • Balance readability vs performance
  • Document optimizations

4. Verify Improvements

  • Measure performance gain
  • Run benchmarks
  • Test edge cases
  • Ensure correctness maintained
  • Check for regressions

Profiling Tools

Python

bash
# CPU profiling
python -m cProfile -o output.prof script.py
python -m cProfile -s cumtime script.py

# Visualize with snakeviz
pip install snakeviz
snakeviz output.prof

# Line profiler
pip install line-profiler
kernprof -l -v script.py

# Memory profiling
pip install memory-profiler
python -m memory_profiler script.py

JavaScript/Node.js

bash
# Node.js profiling
node --prof app.js
node --prof-process isolate-*.log

# Chrome DevTools
# Run with --inspect flag
node --inspect app.js

Shell Scripts

bash
# Time execution
time script.sh

# Detailed timing
hyperfine 'command1' 'command2'

# Profile with bash
PS4='+ $(date "+%s.%N")\011 ' bash -x script.sh

System-Level

bash
# CPU usage
top
htop
mpstat 1

# I/O profiling
iotop
iostat -x 1

# System calls
strace -c command

Common Performance Issues

1. Algorithm Complexity

Problem: Using O(n²) when O(n) or O(n log n) exists

python
# Bad: O(n²)
for item in list1:
    if item in list2:  # O(n) lookup
        process(item)

# Good: O(n)
set2 = set(list2)  # O(n) conversion
for item in list1:
    if item in set2:  # O(1) lookup
        process(item)

2. Unnecessary Loops

Problem: Nested loops, redundant iterations

python
# Bad: Multiple passes
result = [x for x in data if condition1(x)]
result = [x for x in result if condition2(x)]
result = [transform(x) for x in result]

# Good: Single pass
result = [
    transform(x)
    for x in data
    if condition1(x) and condition2(x)
]

3. I/O Bottlenecks

Problem: Too many small reads/writes

python
# Bad: Many small writes
for line in data:
    file.write(line + '\n')

# Good: Batch writes
file.writelines(f'{line}\n' for line in data)

# Better: Buffer writes
with open('file.txt', 'w', buffering=1024*1024) as f:
    f.writelines(f'{line}\n' for line in data)

4. Memory Issues

Problem: Loading everything into memory

python
# Bad: Load entire file
with open('huge.txt') as f:
    data = f.read()
    process(data)

# Good: Stream/iterate
with open('huge.txt') as f:
    for line in f:
        process(line)

5. Database Queries

Problem: N+1 queries, missing indexes

sql
-- Bad: N+1 problem
SELECT * FROM users;
-- Then for each user:
SELECT * FROM posts WHERE user_id = ?;

-- Good: JOIN
SELECT users.*, posts.*
FROM users
LEFT JOIN posts ON users.id = posts.user_id;

-- Also add indexes
CREATE INDEX idx_posts_user_id ON posts(user_id);

Optimization Techniques

Caching

python
from functools import lru_cache

@lru_cache(maxsize=128)
def expensive_function(n):
    # Computed result cached
    return complex_calculation(n)

Lazy Evaluation

python
# Bad: Creates full list
squares = [x**2 for x in range(1000000)]

# Good: Generator (lazy)
squares = (x**2 for x in range(1000000))

Vectorization (NumPy)

python
import numpy as np

# Bad: Python loop
result = [x * 2 + 1 for x in data]

# Good: Vectorized
result = np.array(data) * 2 + 1

Parallel Processing

python
from multiprocessing import Pool

# Process in parallel
with Pool(4) as p:
    results = p.map(process_item, items)

Compile with Cython/Numba

python
from numba import jit

@jit
def fast_function(x, y):
    # Compiled to machine code
    return x ** 2 + y ** 2

Database Optimization

Query Optimization

  • Use EXPLAIN to analyze queries
  • Add indexes on WHERE/JOIN columns
  • Avoid SELECT *, fetch only needed columns
  • Use LIMIT for pagination
  • Batch inserts/updates

Connection Pooling

python
# Reuse connections
pool = ConnectionPool(min=5, max=20)

Caching Layer

  • Redis/Memcached for frequently accessed data
  • Cache query results
  • Set appropriate TTL

Web Performance

Frontend

  • Minimize HTTP requests
  • Compress assets (gzip/brotli)
  • Lazy load images
  • Code splitting
  • Use CDN
  • Browser caching

Backend

  • Use reverse proxy (nginx)
  • Enable HTTP/2
  • Implement rate limiting
  • Async processing for slow tasks
  • Connection keep-alive

Benchmarking Best Practices

Write Good Benchmarks

python
import timeit

# Run multiple times
time = timeit.timeit(
    'function()',
    setup='from __main__ import function',
    number=1000
)

# Compare alternatives
times = {
    'method1': timeit.timeit('method1()', ...),
    'method2': timeit.timeit('method2()', ...),
}

Benchmark Checklist

  • Run on representative data
  • Include warm-up iterations
  • Run multiple times
  • Calculate mean and std dev
  • Test on target hardware
  • Consider different data sizes

Memory Optimization

Reduce Memory Usage

python
# Use generators instead of lists
def read_large_file(file):
    for line in file:
        yield process(line)

# Use __slots__ for classes
class Point:
    __slots__ = ['x', 'y']
    def __init__(self, x, y):
        self.x = x
        self.y = y

Find Memory Leaks

bash
# Python memory profiler
@profile
def my_function():
    pass

# Check reference counts
import sys
sys.getrefcount(object)

Shell Script Optimization

bash
# Avoid unnecessary commands
# Bad
cat file | grep pattern

# Good
grep pattern file

# Use built-ins when possible
# Bad
result=$(date +%s)

# Good (in bash)
printf -v result '%(%s)T' -1

# Parallel execution
# Process files in parallel
find . -name "*.txt" | xargs -P 4 -I {} process {}

When NOT to Optimize

  • Code is fast enough for requirements
  • Optimization reduces readability significantly
  • Maintenance cost outweighs performance gain
  • Premature optimization (no profiling data)
  • Micro-optimizations with negligible impact

Performance Budgets

Set clear targets:

  • Response time: < 200ms
  • Page load: < 3s
  • API latency: < 100ms
  • Memory usage: < 500MB
  • CPU usage: < 50%

Monitoring and Alerts

  • Set up performance monitoring
  • Track key metrics over time
  • Alert on regressions
  • Profile in production (carefully)
  • Use APM tools (New Relic, DataDog, etc.)

Remember: Premature optimization is the root of all evil. Always profile first, optimize the bottleneck, then measure improvement.

Frequently asked questions

What does the Performance Optimizer AI skill do?

Performance analysis, profiling techniques, bottleneck identification, and optimization strategies for code and systems. Use when the user needs to improve performance, reduce resource usage, or identify and fix performance bottlenecks.

Why use Performance Optimizer on TypingMind?

Because you install it once and use it with any model. Performance Optimizer is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Performance Optimizer in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/einverne/dotfiles/tree/master/claude/skills/performance-optimizer. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Performance Optimizer?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Performance Optimizer?

As many as you like. As long as a model supports skills, you can use Performance Optimizer with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Performance Optimizer AI skill free?

Yes. It is published on GitHub by einverne under the GPL-3.0 license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇