Skip to content

Commit 4ba5b99

Browse files
committed
Add MIT license and improve README
Add MIT license file and include it in the Zig package paths. Rewrite README with badges, installation instructions, usage example with parameter docs, architecture diagram, and module descriptions.
1 parent b7b8f9f commit 4ba5b99

3 files changed

Lines changed: 89 additions & 19 deletions

File tree

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 DockYard, Inc.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 67 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,89 @@
11
# flame_on_processor
22

3-
A Zig library that processes flame graph profiling data into [pprof](https://github.com/google/pprof) protobuf format.
3+
[![CI](https://github.com/DockYard/flame_on_processor/actions/workflows/ci.yml/badge.svg)](https://github.com/DockYard/flame_on_processor/actions/workflows/ci.yml)
4+
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
45

5-
Takes semicolon-delimited stack paths with durations, filters out functions below a configurable time threshold, and encodes the result as a pprof `Profile` protobuf.
6+
A Zig library that transforms flame graph profiling data into the [pprof](https://github.com/google/pprof) protobuf format.
67

7-
## Usage
8+
It takes semicolon-delimited stack paths paired with durations, filters out functions that fall below a configurable time threshold, and encodes the result as a pprof `Profile` protobuf — ready for visualization in tools like [pprof](https://github.com/google/pprof) and [speedscope](https://www.speedscope.app).
9+
10+
## Installation
11+
12+
Requires **Zig 0.15.2+**.
13+
14+
```sh
15+
zig fetch --save git+https://github.com/DockYard/flame_on_processor.git
16+
```
17+
18+
Then add the dependency in your `build.zig`:
19+
20+
```zig
21+
const flame_on_processor = b.dependency("flame_on_processor", .{
22+
.target = target,
23+
});
24+
exe.root_module.addImport("flame_on_processor", flame_on_processor.module("flame_on_processor"));
25+
```
826

9-
Add as a Zig package dependency, then import:
27+
## Usage
1028

1129
```zig
1230
const processor = @import("flame_on_processor").processor;
1331
1432
const encoded = try processor.process(
1533
allocator,
16-
&.{ "main;compute", "main;render" },
17-
&.{ 3000, 4000 },
34+
&.{ "main;compute", "main;render", "main;idle" },
35+
&.{ 3000, 4000, 200 },
1836
0.01, // filter threshold: fraction of total time
1937
);
2038
defer allocator.free(encoded);
21-
// `encoded` is pprof protobuf bytes
39+
// `encoded` contains pprof protobuf bytes
2240
```
2341

24-
## Modules
42+
### Parameters
2543

26-
- **processor** — top-level API: filter then encode in one call
27-
- **profile_filter** — removes functions whose inclusive time falls below a threshold fraction, consolidating small subtrees
28-
- **pprof_encoder** — encodes filtered samples into pprof protobuf wire format
29-
- **protobuf** — low-level protobuf encoding primitives
44+
| Parameter | Type | Description |
45+
|-------------|-------------------------|-----------------------------------------------------------------------------|
46+
| `allocator` | `std.mem.Allocator` | Allocator for all internal and returned memory |
47+
| `paths` | `[]const []const u8` | Semicolon-delimited stack traces (e.g. `"main;compute;render"`) |
48+
| `durations` | `[]const u64` | Duration in microseconds for each path (parallel array) |
49+
| `threshold` | `f64` | Fraction of total time below which functions are filtered out (min `0.005`) |
50+
51+
Returns an allocated `[]u8` containing the protobuf-encoded pprof Profile. Caller owns the memory.
52+
53+
## Architecture
54+
55+
```
56+
paths + durations
57+
58+
59+
┌─────────────────┐
60+
│ processor │ top-level API
61+
└────────┬────────┘
62+
63+
┌───────┴───────┐
64+
▼ ▼
65+
┌──────────────┐ ┌──────────────┐
66+
│profile_filter│ │pprof_encoder │
67+
└──────────────┘ └──────┬───────┘
68+
69+
70+
┌──────────────┐
71+
│ protobuf │
72+
└──────────────┘
73+
```
3074

31-
## Building
75+
- **processor** — top-level API: filter then encode in one call
76+
- **profile_filter** — removes functions whose inclusive time falls below the threshold, consolidating small subtrees into placeholder entries
77+
- **pprof_encoder** — encodes filtered samples into pprof protobuf wire format with proper string table deduplication
78+
- **protobuf** — low-level protobuf encoding primitives (varints, length-delimited fields, packed arrays)
3279

33-
Requires Zig 0.15+.
80+
## Development
3481

3582
```sh
36-
zig build # build the library
37-
zig build test # run tests
83+
zig build # build the library
84+
zig build test # run all tests
3885
```
86+
87+
## License
88+
89+
[MIT](LICENSE) - Copyright (c) 2025 DockYard, Inc.

build.zig.zon

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@
7474
"build.zig",
7575
"build.zig.zon",
7676
"src",
77-
// For example...
78-
//"LICENSE",
79-
//"README.md",
77+
"LICENSE",
8078
},
8179
}

0 commit comments

Comments
 (0)