Логотип Performance Optimizer

Performance Optimizer

Спільнота
Firstp1ck
performance-optimizer

Agents should invoke this skill for slow code, high CPU/memory, latency, large data processing, algorithmic complexity, profiling plans, benchmarks, or optimization requests. Profiles first and weighs trade-offs before changing code.

Огляд

ВидавецьFirstp1ck
Репозиторійpi-coding-agent-forge
Назва навичкиperformance-optimizer
Зірки
93
Форки
22
Файли в пакеті
Лише інструкції
ЛіцензіяMIT
Посилання
  • Інструкції у форматі Markdown

    Файл SKILL.md, який модель завантажує за потреби, тож токени витрачаються лише тоді, коли запит справді відповідає навичці.

  • Працює з будь-якою LLM

    Навички ШІ — це звичайний Markdown, а не код для певного постачальника, тому вони працюють із GPT, Claude, Gemini, Grok або локальною моделлю.

  • Усе необхідне — в інструкціях

    Усе потрібне моделі міститься в інструкціях — жодних додаткових файлів для синхронізації.

  • Відкритий вихідний код

    Опубліковано на GitHub користувачем Firstp1ck. Перегляньте вихідний вміст перед установленням.

Встановлення

Установіть навичку ШІ Performance Optimizer у TypingMind, щоб використовувати її з будь-якою LLM, або додайте її до іншого агента, що читає SKILL.md.

1

Встановити в TypingMind

TypingMind встановлює навичку безпосередньо з її папки GitHub — читає SKILL.md, збирає файли ресурсів у пакет і зберігає результат локально.

  1. Відкрийте застосунок і перейдіть до Плагіни → Навички.
  2. Виберіть «Встановити з GitHub».
  3. Вставте наведений нижче URL папки навички та підтвердьте встановлення.
    https://github.com/Firstp1ck/pi-coding-agent-forge/tree/main/pi-skill-performance-optimizer/skills/performance-optimizer
  4. Увімкніть навичку в кожному чаті, де хочете її використовувати.
Плагіни → Навички → Нова навичка → За URL GitHub, потім вставте URL папки й натисніть «Продовжити».
2

Встановити в іншому агенті

Будь-який агент, що підтримує формат Agent Skills, може використовувати цю навичку — скопіюйте папку до каталогу навичок цього агента.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/Firstp1ck/pi-coding-agent-forge.git /tmp/pi-coding-agent-forge
mkdir -p .claude/skills
cp -r /tmp/pi-coding-agent-forge/pi-skill-performance-optimizer/skills/performance-optimizer .claude/skills/performance-optimizer
Після копіювання перезапустіть Claude Code, щоб завантажити нову навичку.

Використовуйте навичку в TypingMind

Увімкніть навичку Performance Optimizer в будь-якому чаті TypingMind, і далі модель усе зробить сама. Назва й опис навички містяться в системному промпті, а щойно надходить відповідний запит, модель самостійно завантажує повні інструкції — вам не потрібно викликати навичку вручну, і до фактичного використання вона не витрачає токенів.

Модель самостійно завантажує навичку Performance Optimizer, щойно надходить відповідний запит.

Працює з будь-якою моделлю ШІ

Навички ШІ — це звичайні інструкції Markdown, а не код для певного постачальника, тому навичка Performance Optimizer не прив’язана до моделі, для якої її створено. Установіть її один раз у TypingMind і використовуйте з GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama або локальною моделлю, яку ви запускаєте самостійно, — усе з вашими власними ключами API.

  • Завантажується лише за потреби

    Системний промпт містить лише назву й опис. Інструкції завантажуються за першого відповідного запиту, тож невикористана навичка нічого не коштує.

  • Змінюйте моделі під час чату

    Оскільки навичка — це інструкції, а не код, зміна моделі не порушує її роботу: наступна модель читає той самий файл SKILL.md.

Інструкції навички

Це вміст файлу SKILL.md, який завантажує модель. Прочитайте його перед установленням — навичка містить інструкції, яких дотримуватиметься ваша модель.

Performance Optimizer

Evidence-based performance optimization. Never optimize without profiling first. Every optimization comes with a trade-off analysis.

Quick Start

Investigate a Performance Issue

  1. Reproduce: Can you reliably reproduce the slowness? What are the conditions?
  2. Measure: Profile to find the actual bottleneck. Don't guess.
  3. Analyze: What's the root cause? Algorithm? I/O? Memory? Contention?
  4. Propose: 2-3 options with trade-offs (speed vs readability, memory vs CPU, etc.)
  5. Verify: After optimization, re-measure to confirm improvement.

The cardinal rule: Profile first, optimize second. Gut feelings about performance are wrong more often than right.


Profiling Toolkits

Rust

ToolPurposeCommand
cargo benchMicro-benchmarks (criterion)cargo bench
cargo flamegraphCPU flamegraph visualizationcargo flamegraph --bin <name>
perfLinux perf eventsperf record --call-graph dwarf ./target/release/<bin>
valgrind --tool=callgrindInstruction-level profilingvalgrind --tool=callgrind ./target/release/<bin>
cargo bloatBinary size analysiscargo bloat --release
DHAT (via valgrind)Heap allocation profilingvalgrind --tool=dhat ./target/release/<bin>

Quick benchmark setup with criterion:

rust
// benches/my_bench.rs
use criterion::{criterion_group, criterion_main, Criterion};

fn benchmark_function(c: &mut Criterion) {
    c.bench_function("descriptive name", |b| {
        b.iter(|| {
            // code to benchmark
        })
    });
}

criterion_group!(benches, benchmark_function);
criterion_main!(benches);

TypeScript / React

ToolPurposeHow
React DevTools ProfilerComponent render timingBrowser extension, Profiler tab
LighthouseOverall web performanceChrome DevTools > Lighthouse
console.time() / console.timeEnd()Quick timingWrap suspicious code
webpack-bundle-analyzerBundle size analysisbun run build --analyze
performance.mark() / performance.measure()Web Performance APIPrecise timing of code sections
React <Profiler> componentProgrammatic render profilingWrap components in <Profiler>

Key React performance checks:

  • Unnecessary re-renders (use React DevTools "Highlight updates")
  • Large component trees re-rendering from state at the top
  • Missing useMemo / useCallback for expensive computations or stable references
  • Bundle size — are you importing entire libraries for one function?

Django / Python

ToolPurposeCommand
django-debug-toolbarSQL queries, template timingAdd to INSTALLED_APPS
cProfileFunction-level profilingpython -m cProfile -s cumtime manage.py <command>
py-spySampling profiler (no code changes)py-spy record -o profile.svg -- python manage.py runserver
silkDjango request/response profilingAdd to middleware
memory_profilerLine-by-line memory usage@profile decorator
django.db.connection.queriesRaw SQL query logfrom django.db import connection; print(connection.queries)

Key Django performance checks:

  • N+1 queries (use django-debug-toolbar or assertNumQueries in tests)
  • Missing database indexes on filtered/ordered columns
  • Unoptimized querysets (use .only(), .defer(), .values() when appropriate)
  • Template rendering time (are you doing computation in templates?)

Complexity Analysis

Big-O Quick Reference

ComplexityNameExampleScale
O(1)ConstantHashMap lookupHandles any size
O(log n)LogarithmicBinary searchHandles billions
O(n)LinearSingle pass over collectionHandles millions
O(n log n)LinearithmicGood sorting (merge, heap)Handles millions
O(n^2)QuadraticNested loops over same collectionHandles thousands
O(n^3)CubicTriple nested loopsHandles hundreds
O(2^n)ExponentialBrute-force subsetsHandles ~25

When to Care

  • O(1) to O(n): Almost never a problem. Don't optimize.
  • O(n log n): Fine for most use cases. Only optimize for very hot paths.
  • O(n^2): Watch the input size. Fine for n < 1000, problematic for n > 10000.
  • O(n^3) or worse: Red flag. Look for algorithmic improvements first.

Cyclomatic and Data Flow Complexity

Per the project coding standards:

  • Cyclomatic complexity: Must be < 25 per function
  • Data flow complexity: Must be < 25 per function

When complexity exceeds these thresholds, the refactoring-advisor skill should be used to plan decomposition.


Common Optimization Patterns

Rust-Specific

PatternWhenTrade-off
Replace Vec<Box<dyn Trait>> with enum dispatchKnown, finite set of variantsLess flexible, but no heap allocation per item
Use &str instead of StringFunction doesn't need ownershipLifetime annotations may complicate API
Pre-allocate with Vec::with_capacity()Known or estimated collection sizeMinor memory overhead if estimate is wrong
Use SmallVecUsually-small collectionsExtra dependency, more complex type
Replace clone() with borrowsCloning on hot pathsMore lifetime management
Use rayon for data parallelismCPU-bound work on large collectionsThread pool overhead for small collections

React/TypeScript-Specific

PatternWhenTrade-off
React.memo()Component re-renders with same propsExtra memory for memoized result, stale risk if deps wrong
useMemo / useCallbackExpensive computation or stable reference neededComplexity, memory for cache
Code splitting with React.lazy()Large bundles, route-level splittingLoading states, waterfall risk
Virtualized lists (react-window)Rendering 100+ items in a listMore complex implementation
Debounce/throttleFrequent events (scroll, resize, input)Delayed response

Django/Python-Specific

PatternWhenTrade-off
select_related()ForeignKey lookups in loopsLarger initial query, but fewer total queries
prefetch_related()Reverse FK / M2M lookups in loopsExtra query, but bounded number of queries
.values() / .values_list()Only need specific columnsLose model instance methods
Database indexesFrequently filtered/ordered columnsSlower writes, disk space
Caching (django.core.cache)Expensive queries repeated oftenStale data risk, cache invalidation complexity
Bulk operationsCreating/updating many rowsLess granular error handling

Trade-Off Analysis Template

When recommending an optimization, always present:

markdown
### Optimization: [Description]

**Current:** [What's happening now, with measured performance]
**Proposed:** [What to change]

| Dimension | Before | After |
|---|---|---|
| Time complexity | O(n^2) | O(n log n) |
| Space complexity | O(1) | O(n) |
| Readability | Simple nested loop | Sort + scan requires comment |
| Maintainability | Easy to modify | Requires understanding of invariant |

**Recommendation:** [Proceed / Defer / Skip]
**Justification:** [Why this trade-off is or isn't worth it in this context]

Anti-Patterns: When NOT to Optimize

  • Premature optimization. If there's no measured performance problem, don't create complexity to solve one.
  • Micro-optimizing cold paths. That function called once at startup? Leave it readable.
  • Optimizing without benchmarks. "I think this is slow" is not evidence. Profile first.
  • Sacrificing correctness for speed. Fast and wrong is worse than slow and right.
  • Cargo-culting. "I read that HashMap is faster" — depends on the size, access pattern, and key type. Measure in your context.

Integration

  • Data: Performance findings logged to MEMORY.md
  • Tools: Can run profiling/benchmarking tools without asking (see execution policies in AGENTS.md)
  • Refactoring: When optimization requires restructuring, use the refactoring-advisor skill for safe migration planning
  • Trade-offs: Every optimization recommendation includes a trade-off table

Arc skill — Performance profiling and optimization

Поширені запитання

Що робить навичка ШІ Performance Optimizer?

Agents should invoke this skill for slow code, high CPU/memory, latency, large data processing, algorithmic complexity, profiling plans, benchmarks, or optimization requests. Profiles first and weighs trade-offs before changing code.

Навіщо використовувати Performance Optimizer у TypingMind?

Тому що ви встановлюєте її один раз і використовуєте з будь-якою моделлю. Performance Optimizer — це звичайний Markdown, а не код для конкретного постачальника, тому та сама навичка працює з GPT-5, Claude, Gemini, Grok або локальною моделлю. Ви можете змінити модель навіть посеред чату, і навичка продовжить працювати. TypingMind використовує ваші власні ключі API, тож ви платите безпосередньо постачальникам замість передплати за кожне місце користувача, а ваші навички й чати залишаються у вашому сховищі.

Як встановити Performance Optimizer у TypingMind?

Відкрийте в TypingMind Плагіни → Навички → Встановити з GitHub і вставте https://github.com/Firstp1ck/pi-coding-agent-forge/tree/main/pi-skill-performance-optimizer/skills/performance-optimizer. TypingMind прочитає файл SKILL.md і встановить навичку, яку можна вмикати окремо для кожного чату.

Які моделі ШІ можуть використовувати Performance Optimizer?

Будь-яка модель, яку ви підключите в TypingMind. Навички ШІ — це звичайні інструкції у форматі Markdown, а не код для конкретного постачальника, тому GPT, Claude, Gemini, Grok і локальні моделі можуть завантажувати цю навичку, коли запит їй відповідає.

Зі скількома моделями ШІ можна використовувати Performance Optimizer?

Зі скількома забажаєте. Якщо модель підтримує навички, ви можете використовувати з нею Performance Optimizer — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama та інші — усе в TypingMind із власними ключами API.

Чи безкоштовна навичка ШІ Performance Optimizer?

Так. Навичку опубліковано на GitHub: Firstp1ck, за ліцензією MIT. Ви платите лише своєму постачальнику ШІ за використані токени.

Що таке навички ШІ?

Навичка ШІ — це багаторазовий набір інструкцій, який навчає модель ШІ виконувати одне конкретне завдання. Він відповідає відкритому формату Agent Skills: файл SKILL.md із назвою та описом, а також скрипти, шаблони чи довідкові файли, які можуть знадобитися моделі. Модель читає інструкції лише тоді, коли ваш запит відповідає навичці, тому встановлена навичка нічого не коштує, доки її не використано.

Чим навички ШІ відрізняються від плагінів або серверів MCP?

Плагін або сервер MCP надає моделі нові інструменти для виклику — код, який десь виконується й повертає результат. Натомість навичка ШІ надає моделі знання та порядок дій: як підійти до завдання, яких кроків дотримуватися та яким має бути якісний результат. Навички — це звичайний Markdown, тож їм не потрібні ні сервер, ні ключ API, ні середовище виконання, і вони працюють із будь-якою моделлю.

Усі

Створіть власний ШІ-простір уже зараз

Підпишіться на нашу розсилку, щоб дізнаватися про нові функції та майбутні розіграші 👇