Skip to content

Commit 69585c3

Browse files
authored
Merge pull request #66 from arielb1/decode-no-pollcatch
feat: improve handling of decoding non-pollcatch samples
2 parents dd4cab6 + 9521003 commit 69585c3

File tree

4 files changed

+228
-58
lines changed

4 files changed

+228
-58
lines changed

README.md

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,19 @@ The metadata is not used by the agent directly, and only provided to the reporte
8181
If you want to find long poll times, and you have `RUSTFLAGS="--cfg tokio_unstable"`, you can
8282
emit `tokio.PollCatchV1` events this way:
8383

84-
```
84+
```rust
8585
#[cfg(tokio_unstable)]
8686
{
8787
rt.on_before_task_poll(|_| async_profiler_agent::pollcatch::before_poll_hook())
8888
.on_after_task_poll(|_| async_profiler_agent::pollcatch::after_poll_hook());
8989
}
9090
```
9191

92+
If you can't use `tokio_unstable`, it is possible to wrap your tasks by instrumentation that calls
93+
`before_poll_hook` before user code runs and `after_poll_hook` after user code runs, but that
94+
runs the risk of forgetting to instrument the task that is actually causing the high latency,
95+
and therefore it is strongly recommended to use `on_before_task_poll`/`on_after_task_poll`.
96+
9297
### Not enabling the AWS SDK / Reqwest default features
9398

9499
The `aws-metadata-no-defaults` and `s3-no-defaults` feature flags do not enable feature flags for the AWS SDK and `reqwest`.
@@ -139,6 +144,50 @@ The output should look like this
139144

140145
If it does not work, make sure you are using the most recent version of `async-profiler` and that you enabled the pollcatch hooks.
141146

147+
### Missing samples
148+
149+
If you are missing pollcatch samples, you can also run the decoder with `--include-non-pollcatch` and a time
150+
filter of 0 us to see all samples, as in:
151+
152+
```
153+
./decoder/target/release/pollcatch-decoder longpolls --include-non-pollcatch --zip profile_WHATEVER_*.zip
154+
```
155+
156+
#### Samples are still not showing
157+
158+
If the samples are still missing, this is probably a problem with async-profiler or its use. Make sure you are using
159+
async-profiler correctly.
160+
161+
#### Sample found with "sample with no pollcatch information"
162+
163+
If this discovers the samples as "sample with no pollcatch information", for example:
164+
165+
```
166+
[87.831540] thread 1878 - sample with no pollcatch information
167+
- 1: libc.so.6.clock_nanosleep
168+
- 52 more frame(s) (pass --stack-depth=53 to show)
169+
```
170+
171+
It is likely that you do not have pollcatch enabled correctly. Make sure you are using the [`before_poll_hook`
172+
and `after_poll_hook` hooks][pollcatch], which normally requires using `--cfg tokio_unstable`. Also make sure that
173+
you are using async-profiler that supports user events (`v4.0` or higher, if you are using official versions
174+
from upstream).
175+
176+
[pollcatch]: #pollcatch
177+
178+
### Dealing with `unknown` frames / truncated stack traces
179+
180+
If you are seeing `unknown` frames, this indicates that `async-profiler` has problems finding unwinding
181+
information. There are 2 normal causes for that:
182+
183+
1. Your code, or the code of some library you are using, is missing debuginfo. To fix that, compile your
184+
code with `debuginfo` or at least `debuginfo-lines`.
185+
2. The running stack frame contains code that is generated by a JIT. Current versions of `async-profiler`
186+
support unwinding JVM frames, but frames generated by other JITs will show up as `unknown`.
187+
188+
`async-profiler` is often not capable of unwinding past `unknown` frames, so they will often "truncate"
189+
the stack trace which will not go past one or two `unknown` frames.
190+
142191
[`jfrs`]: https://docs.rs/jfrs
143192

144193
## Security
@@ -147,4 +196,4 @@ See [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more inform
147196

148197
## License
149198

150-
This project is licensed under the Apache-2.0 License.
199+
This project is licensed under the Apache-2.0 License.

decoder/Cargo.lock

Lines changed: 34 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

decoder/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,6 @@ tracing = "0.1"
1818
tracing-subscriber = { version = "0.3", features = ["fmt"] }
1919
zip = "2.6"
2020
serde = "1"
21+
22+
[dev-dependencies]
23+
test-case = "3"

0 commit comments

Comments
 (0)