Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(perf) Add continuous profiling support #482

Merged
merged 1 commit into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ pub fn build(b: *Build) void {
.optimize = optimize,
.sanitize_thread = enable_tsan,
});

// make sure pyroscope's got enough info to profile
sig_exe.build_id = .fast;
sig_exe.root_module.omit_frame_pointer = false;
sig_exe.root_module.strip = false;

b.installArtifact(sig_exe);
sig_exe.root_module.addImport("base58-zig", base58_module);
sig_exe.root_module.addImport("curl", curl_mod);
Expand Down
1 change: 1 addition & 0 deletions metrics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ linux: `docker compose up -d`
- prometheus will be accessable on `localhost:9090`
- sig metrics will be published to localhost:12345 (if you change this on the sig cli, you will
need to also modify the prometheus `target` to point to the different port).
- To enable profiling, optionally supply SIG_PID `e.g. SIG_PID=$(pgrep sig) docker compose up -d`

## Shutting down

Expand Down
15 changes: 15 additions & 0 deletions metrics/alloy/config.alloy
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,18 @@ loki.write "grafana_loki" {
url = "http://loki:3100/loki/api/v1/push"
}
}

pyroscope.ebpf "instance" {
forward_to = [pyroscope.write.endpoint.receiver]
targets = [{
__process_pid__ = env("SIG_PID"),
service_name = "sig",
}]

}

pyroscope.write "endpoint" {
endpoint {
url = "http://pyroscope:4040"
}
}
15 changes: 15 additions & 0 deletions metrics/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ services:
alloy:
image: grafana/alloy:v1.3.1
container_name: alloy

# needed to access sig process
pid: "host"
privileged: true

ports:
- "3200:3200"
volumes:
Expand All @@ -41,6 +46,8 @@ services:
"--server.http.listen-addr=0.0.0.0:3200",
"/etc/alloy/config.alloy",
]
environment:
- SIG_PID=${SIG_PID}

grafana:
image: grafana/grafana
Expand All @@ -63,5 +70,13 @@ services:
- 9100:9100
restart: unless-stopped

pyroscope:
image: grafana/pyroscope:1.11.0
container_name: pyroscope
ports:
- "4040:4040"
environment:
- STORAGE_DRIVER=in-memory

volumes:
prom_data:
4 changes: 4 additions & 0 deletions metrics/grafana/datasources/datasource.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ datasources:
isDefault: false
version: 1
editable: false

- name: Pyroscope
type: grafana-pyroscope-datasource
url: http://pyroscope:4040
Loading