Przejdź do treści
Biblioteka skilli
Programowanie · Analiza

profiling-cpu

/profiling-cpu

Znajduje kod zużywający czas procesora za pomocą profilera próbkującego i flame graphu, zanim ktokolwiek zacznie zmieniać program.

Repozytorium
AI-SKILLS ↗
Licencja
MIT
Ostatnia zmiana repozytorium
05.09.2026

Ocena i bezpieczeństwo

90/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść25 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
1
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
0
Przestarzałość

Brak sygnałów. Repozytorium zmienione 05.09.2026, bez odwołań do wycofanych modeli i API.

Licencja

MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.

Co robi i kiedy

Znajduje kod zużywający czas procesora za pomocą profilera próbkującego i flame graphu, zanim ktokolwiek zacznie zmieniać program.

Oryginalny opis (EN)

Find the code that actually burns CPU time using a sampling profiler and a flame graph instead of guesswork. Use when a program is slower than it should be and you need to locate the hot path before touching any code.

Jak działa

  1. Method
  2. Litmus tests
  3. Boundaries
Sekcje z nagłówków SKILL.md, w oryginale · 51 linii, 457 słów
Podgląd SKILL.md
---
name: profiling-cpu
description: Find the code that actually burns CPU time using a sampling profiler and a flame graph instead of guesswork. Use when a program is slower than it should be and you need to locate the hot path before touching any code.
---

# Profiling CPU

Intuition about what is slow is wrong often enough that acting on it wastes
days. The bottleneck is rarely the clever algorithm you remember writing; it
is a string format in a loop or a lock nobody noticed. A profiler replaces the
guess with a measurement of where cycles go.

## Method

1. **Reach for a sampling profiler, not an instrumenting one.** Sampling
   interrupts the program hundreds of times a second and records the stack:
   `perf record -F 999 -g -- ./app` on Linux, `py-spy record -o out.svg --
   python app.py` for Python, `async-profiler` for the JVM. Instrumenting
   every call (like `cProfile`) distorts the very timings you are measuring.
2. **Profile a release build under a real workload.** Debug builds and
   toy inputs move the hot spot somewhere it will never be in production.
   Compile with optimizations on, feed the profiler the traffic or dataset
   that actually hurts, and run long enough to collect tens of thousands of
   samples so the numbers are stable.
3. **Read the flame graph by width, not by height.** Width is time: the
   widest frame at any level spent the most CPU. Height is only call depth
   and means nothing on its own. Scan the top edge of the graph, the leaf
   frames doing the actual work, and find the widest plateau.
4. **Separate self time from total time.** A function wide because its
   children are wide is not the culprit; drill into the child. A leaf that is
   wide with no children below it is burning cycles itself: that is where an
   optimization pays off. `perf report` shows this split as self vs children.
5. **Follow surprise frames into system and runtime code.** A fat
   `malloc`, `memcpy`, garbage-collection, or futex plateau names the real
   problem: allocation churn, copying, or lock contention rather than your
   arithmetic. The named syscall or runtime function tells you which fix
   applies before you read a line of your own source.
6. **Fix the widest bar, then reprofile from scratch.** Optimizing anything
   but the top item moves numbers you will not feel. After one change, capture
   a fresh graph: the hot spot has usually moved, and the old profile no
   longer describes the program.

## Litmus tests

- Can you name the single function with the largest self time, in samples?
- Did the graph come from an optimized build under representative load?
- After your change, did the widest plateau shrink or just shift elsewhere?

## Boundaries

A CPU profile explains where compute goes, not where wall-clock time goes. A
program blocked on disk, network, or a lock sits idle off-CPU and barely
appears; use off-CPU profiling or tracing for that. For allocation pressure
specifically, an allocation profiler attributes the churn more directly.

Wersje

W bazie nie ma innych skilli o nazwie profiling-cpu.

Migawka bazy z 28.10.2026 · wersja paczki ed88f84855ac (skrót SHA-256 całej paczki)

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 100profiling
    Wskazuje, gdzie działający system traci czas, pamięć i IO, korzystając z profilerów CPU i pamięci oraz wykresów płomieniowych.
  • 100flame-graph-analyzer
    Czyta wyniki flame graph z py-spy, async-profiler, Go pprof i Node.js: wskazuje gorącą ścieżkę, klasyfikuje wąskie gardło (CPU, blokady, alokator) i proponuje kolejny krok.
  • 100flame-graph-generator
    Prawdopodobnie generuje flame graphy do testów wydajności i analizy profili.
  • 95nodejs-profiling
    Profiluje wydajność Node.js za pomocą profilera CPU V8, analizy sterty i perf_hooks, żeby znaleźć wąskie gardła, wycieki pamięci i opóźnienia pętli zdarzeń.
  • 100163-java-profiling-refactor
    Refaktoryzuje kod Java na podstawie wyników profilowania, usuwając konkretne wąskie gardła procesora, pamięci i wątków.
  • 100cx-profiling
    Przeszukuje dane profilowania ciągłego Coralogix: które usługi zużywają najwięcej CPU lub pamięci, kiedy nastąpił skok i który kod go spowodował, z wykresami płomieni.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.