rel:: [[Performance|performance]]
# Profiling
## Methodology
- [[Method R]]
- ![[Method R#^42e012]]
## Reference
- [profilerpedia](https://profilerpedia.markhansen.co.nz/)
### formats
- [[Java Flight Recorder|JFR]]
- [[pprof]]
- [perfetto](https://perfetto.dev/docs/design-docs/api-and-abi#tracing-protocol-abi) ^244319
- [profilerpedia/formats](https://profilerpedia.markhansen.co.nz/formats/)
#### firefox profiler
- [firefox profiler](https://profiler.firefox.com/)
- [source](https://github.com/firefox-devtools/profiler)
- [user docs](https://profiler.firefox.com/docs/#/)
- dev
- [firefox source docs / Gecko Profiler](https://firefox-source-docs.mozilla.org/tools/profiler/index.html)
- two formats
- [gecko profile format](https://github.com/firefox-devtools/profiler/blob/main/docs-developer/gecko-profile-format.md)
- [ProfileBufferEntry.h](https://searchfox.org/mozilla-central/rev/5966e98bdfa7355e0a3d9cce482f4717dc3419b0/tools/profiler/core/ProfileBufferEntry.h#358)
- profiler.firefox.com format
- [profile.js](https://github.com/firefox-devtools/profiler/blob/main/src/types/profile.js)
- [mostlynerdless commentary on format](https://readwise.io/reader/shared/01gstcnsj4myb2vntbvcn9addq)
- [custom importer](https://github.com/firefox-devtools/profiler/blob/main/docs-developer/custom-importer.md)
- [markers](https://github.com/firefox-devtools/profiler/blob/main/docs-developer/markers.md)
- usage
- [Firefox Profiler beyond the web | Mostly nerdless](https://mostlynerdless.de/blog/2023/01/31/firefox-profiler-beyond-the-web/)
- issues
- [4462 Support go's pprof format](https://github.com/firefox-devtools/profiler/issues/4462)
### Java
- [async-profiler](https://github.com/jvm-profiling-tools/async-profiler)
- [datadog java-profiler-library](https://github.com/DataDog/java-profiler-library)
- [jvm-profiling-tools/ap-loader](https://github.com/jvm-profiling-tools/ap-loader) - Packages async-profiler with binaries for all platforms in a single JAR
- [JEP 435 Asynchronous Stack Trace VM API](https://openjdk.org/jeps/435)
### [[golang]]
- [[Felix Geisendörfer#Go Profiler Notes]]
- PGO - [Profile Guided Optimization workflow](https://readwise.io/reader/shared/01gs8xwfgbg9q97806bfbk4b4a)
- [preview in 1.20](https://readwise.io/reader/shared/01gs8xz4mn2t2t3r1bj3rs50m9)
### [[linux]]
- [[Performance Matters]] talk on Coz
- [coz profiler](https://github.com/plasma-umass/coz) - Coz is a new kind of profiler that unlocks optimization opportunities missed by traditional profilers. Coz employs a novel technique we call causal profiling that measures optimization potential. This measurement matches developers' assumptions about profilers: that optimizing highly-ranked code will have the greatest impact on performance. Causal profiling measures optimization potential for serial, parallel, and asynchronous programs without instrumentation of special handling for library calls and concurrency primitives. Instead, a causal profiler uses performance experiments to predict the effect of optimizations. This allows the profiler to establish causality: "optimizing function X will have effect Y," exactly the measurement developers had assumed they were getting all along.
#### perf
```bash
# count the perf things for <program>
perf stat -e branches,branch-misses,cache-references,cache-misses,cycles,instructions,idle-cycles-backend,idle-cycles-frontend,task-clock -- <program>
```
### Profiler Tools
- [[dd/profiling]]
### Frame Unwinding
- [Frame pointers and other practical near-term solutions](https://readwise.io/reader/shared/01gnx6bya83drtn3aksaynwt3h)
- [How Universal Profiling unwinds stacks without frame pointers and symbols](https://readwise.io/reader/shared/01gnx19nqgvhedq9zzdctxex2s)
- [[Nick Ripley]]'s [DWARF unwinding research notes](x-devonthink-item://D09FD37D-5D26-4E80-A760-B231AE9CE551)
- [Oct 4, 2022 Go/CGO Call Stack Discussion on Slack](x-devonthink-item://F3E44D83-08A0-4874-882B-D15E61D4A1DD)
- [[202301261109 Slack Thread Frame Unwinding in Fedora]]
### Sample Signals
- [[202302151703 Slack thread on profile CPU vs k8s CPU metric]]
#### [[Java]]
- [[Java Flight Recorder|JFR]]
- [[JDK Mission Control|JMC]]
- [[async-profiler]]
- [[Java String Concatenation]]
### Databases
- [[SQL#^79178d|flamegraphs and sql plan execution]]