Skip to content

Commit

Permalink
add continuous profiling support (Syndica#482)
Browse files Browse the repository at this point in the history
Sobeston authored Jan 7, 2025
1 parent 00ec2fe commit 0fb04c6
Showing 5 changed files with 41 additions and 0 deletions.
6 changes: 6 additions & 0 deletions build.zig
Original file line number Diff line number Diff line change
@@ -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);
1 change: 1 addition & 0 deletions metrics/README.md
Original file line number Diff line number Diff line change
@@ -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

15 changes: 15 additions & 0 deletions metrics/alloy/config.alloy
Original file line number Diff line number Diff line change
@@ -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
@@ -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:
@@ -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
@@ -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
@@ -14,3 +14,7 @@ datasources:
isDefault: false
version: 1
editable: false

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

0 comments on commit 0fb04c6

Please sign in to comment.