parca-dev / parca-agent

eBPF based always-on profiler auto-discovering targets in Kubernetes and systemd, zero code changes or restarts needed!
https://parca.dev/
Apache License 2.0
549 stars 68 forks source link

Ensure cache keys using PID are unique #984

Open maxbrunet opened 2 years ago

maxbrunet commented 2 years ago

One small comment about something we need to revisit in the Agent as a whole is that caching PIDs can be problematic due to them being reused.

We should be able to add the starttime field of /proc/[pid]/stat to the cache key: awk '{print $23}' "/proc/${pid}/stat"

https://pkg.go.dev/github.com/prometheus/procfs#ProcStat.StartTime

Originally posted by @maxbrunet in https://github.com/parca-dev/parca-agent/issues/960#issuecomment-1300932155

There are at least two caches to look into, in the discovery manager and in the label manager

cc @javierhonduco @kakkoyun

javierhonduco commented 2 years ago

Yes! Exactly the approach I had in mind :). It's how I implemented a similar logic in rbperf to ensure that the right process is profiled, and was planning on reworking all this in the Agent at some point