Skip to content

Commit 08236c9

Browse files
authored
Merge pull request #21 from arielb1/add-decoder
add decoder implementation
2 parents f532aae + ce8e817 commit 08236c9

File tree

9 files changed

+1705
-16
lines changed

9 files changed

+1705
-16
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Build (decoder)
2+
on: [pull_request]
3+
4+
jobs:
5+
build:
6+
runs-on: ubuntu-latest
7+
env:
8+
RUST_BACKTRACE: 1
9+
steps:
10+
- uses: actions/checkout@v4
11+
- uses: dtolnay/rust-toolchain@master
12+
with:
13+
toolchain: stable
14+
- uses: Swatinem/rust-cache@v2
15+
with:
16+
cache-directories: decoder
17+
- name: Build
18+
working-directory: decoder
19+
shell: bash
20+
run: cargo build --all-features --verbose
21+
- name: Run tests
22+
working-directory: decoder
23+
shell: bash
24+
run: cargo test --all-features --verbose

.github/workflows/format.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ jobs:
1515
id: cargoFmt
1616
shell: bash
1717
run: cargo fmt --all -- --check
18+
- name: Run fmt check - decoder
19+
id: cargoFmtDecoder
20+
shell: bash
21+
working-directory: decoder
22+
run: cargo fmt --all -- --check
1823
clippy:
1924
name: Cargo clippy
2025
runs-on: ubuntu-latest
@@ -26,3 +31,17 @@ jobs:
2631
id: cargoClippy
2732
shell: bash
2833
run: cargo clippy --workspace --all-features -- -D warnings
34+
clippyDecoder:
35+
name: Cargo clippy (decoder)
36+
runs-on: ubuntu-latest
37+
steps:
38+
- uses: actions/checkout@v4
39+
- uses: dtolnay/rust-toolchain@stable
40+
- uses: Swatinem/rust-cache@v2
41+
with:
42+
cache-directories: decoder
43+
- name: Run clippy check - decoder
44+
id: cargoClippyDecoder
45+
shell: bash
46+
working-directory: decoder
47+
run: cargo clippy --workspace --all-features -- -D warnings

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
/target
2+
/decoder/target

CONTRIBUTING.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ Then make a new PR for the release and get it approved.
5757

5858
The automated release PR generation functionality is not used here.
5959

60-
This requires a crates.io token in GitHub secrets for the repo. Currently the "token" is literally the string `secret` but I will put a more realistic token once the repo is public.
61-
6260
[conventional commits]: https://www.conventionalcommits.org/en/v1.0.0/
6361

6462
## Code of Conduct

Cargo.lock

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

README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,52 @@ emit `tokio.PollCatchV1` events this way:
8484
}
8585
```
8686

87+
## Decoder
88+
89+
The `decoder` directory in the Git repository contains a decoder that can be used to view JFR files, especially with PollCatch information.
90+
91+
The decoder is NOT intended right now to be used in production. In particular, it uses the [`jfrs`] crate for parsing `.jfr` files, and while that crate seems to be purely safe Rust, to my knowledge it has not been audited for security and probably contains at least denial-of-service issues if not worse.
92+
93+
If you want to use the decoder for anything but debugging on trusted `.jfr` files, you bear full responsibility for the consequences.
94+
95+
To use the decoder, you can download the `.zip` file from s3, and then run it:
96+
```
97+
aws s3 cp s3://your-bucket/YOUR_PROFILE.zip .
98+
# the last parameter is the long poll threshold
99+
./decoder/target/release/pollcatch-decoder longpolls --zip profile_WHATEVER_*.zip 500us
100+
```
101+
102+
The output should look like this
103+
```
104+
[930689.953296] thread 60898 - poll of 8885us
105+
- 1: libpthread-2.26.so.__nanosleep
106+
- 2: simple.std::thread::sleep_ms
107+
- 3: simple.simple::slow::accidentally_slow
108+
- 4: simple.simple::slow::accidentally_slow_2
109+
- 5: simple.simple::slow::run::{{closure}}::{{closure}}
110+
- 16 more frame(s) (pass --stack-depth=21 to show)
111+
112+
[930691.953294] thread 60898 - poll of 736us
113+
- 1: libpthread-2.26.so.__nanosleep
114+
- 2: simple.std::thread::sleep_ms
115+
- 3: simple.simple::slow::accidentally_slow
116+
- 4: simple.simple::slow::accidentally_slow_2
117+
- 5: simple.simple::slow::run::{{closure}}::{{closure}}
118+
- 16 more frame(s) (pass --stack-depth=21 to show)
119+
120+
[930709.953293] thread 60898 - poll of 2736us
121+
- 1: libpthread-2.26.so.__nanosleep
122+
- 2: simple.std::thread::sleep_ms
123+
- 3: simple.simple::slow::accidentally_slow
124+
- 4: simple.simple::slow::accidentally_slow_2
125+
- 5: simple.simple::slow::run::{{closure}}::{{closure}}
126+
- 16 more frame(s) (pass --stack-depth=21 to show)
127+
```
128+
129+
If it does not work, make sure you are using the most recent version of `async-profiler` and that you enabled the pollcatch hooks.
130+
131+
[`jfrs`]: https://docs.rs/jfrs
132+
87133
## Security
88134

89135
See [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more information.

0 commit comments

Comments
 (0)