Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

add pyroscope #4871

Merged
merged 14 commits into from
Feb 22, 2022
Merged

add pyroscope #4871

merged 14 commits into from
Feb 22, 2022

Conversation

drahnr
Copy link
Contributor

@drahnr drahnr commented Feb 8, 2022

This is a test to see if this yields better results compared to just ebpf for the binary

@github-actions github-actions bot added the A0-please_review Pull request needs code review. label Feb 8, 2022
@ordian
Copy link
Member

ordian commented Feb 8, 2022

cc grafana/pyroscope#370

@drahnr drahnr requested a review from a team as a code owner February 8, 2022 17:14
cli/src/cli.rs Outdated Show resolved Hide resolved
cli/Cargo.toml Outdated Show resolved Hide resolved
Cargo.toml Outdated Show resolved Hide resolved
@drahnr drahnr added B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. labels Feb 9, 2022
Copy link
Member

@ordian ordian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@PierreBesson
Copy link
Contributor

I think to be complete, this PR should also have some docs on how to use Pyroscope with a local or remote server, similar to what we have for the Grafana readme.

@drahnr
Copy link
Contributor Author

drahnr commented Feb 10, 2022

At a second thought, I think we don't need this kind of readme for pyroscope. We don't have this for jaeger/tempo either. grafana is a bit of special case since we have the dashboard exports in there and to make changes, using them is a prerequisite and the whole usage pattern is significantly more complex.

.gitlab-ci.yml Show resolved Hide resolved
.gitlab-ci.yml Show resolved Hide resolved
Fixes an underflow panic.
Copy link
Contributor

@vstakhov vstakhov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a suggestion to use url instead of a hostname:port construct.

cli/src/command.rs Outdated Show resolved Hide resolved
@@ -293,6 +304,31 @@ where
pub fn run() -> Result<()> {
let cli: Cli = Cli::from_args();

#[cfg(feature = "pyroscope")]
let mut pyroscope_agent_maybe = if let Some(ref agent_addr) = cli.run.pyroscope_server {
let address = agent_addr
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need an address resolution here in the first place, counting that we reconstruct an URL afterwards? This URL can support more than plain http, for example https. I have no strong opinion here, but maybe it is better to name option like pyroscope_url and treat it as an URL from the beginning?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two competing things: We want compatibility, but we also want URLs. url::Url does not accept an IP without a prefixed protocol such as tcp:// or http:// - but we must maintain compatibility. The above is an escape hatch to reduce either to an IP address and avoid the ordeal.

"http://".to_owned() + address.to_string().as_str(),
"polkadot".to_owned(),
)
.sample_rate(100)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, flamegraph creator recommends1

The odd numbered rates, 99 and 199, are used to avoid sampling in lockstep with other activity and producing misleading results.

And not-perf uses 900 by default2. @koute any insights on this?

Footnotes

  1. https://www.brendangregg.com/FlameGraphs/cpuflamegraphs.html

  2. https://cs.github.com/koute/not-perf/blob/e75188b1067e11c692ed172dc1333a6a031ef55c/src/args.rs?q=900#L170

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made the sample rate a prime number above 100, to retain accuracy and not introduce too much overhead. This is just an initial number, we'll have to adjust this based on practical experience, hence I'd like to keep this on the lower, less invasive side for the time being.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think it's a good idea to pick a "less round" sampling rate.

For not-perf there wasn't really any deep meaning behind why I picked 900, besides the fact that I wanted it high to make the results more detailed/reliable.

cli/src/command.rs Outdated Show resolved Hide resolved
@koute
Copy link
Contributor

koute commented Feb 22, 2022

BTW, do we already have some example flamegraphs or any other data that this generates? I'm curious how it'll handle our codebase compared to my profiler, especially whether it'll be able to gather full stack traces and whether it can properly demangle everything and decode inline frames along with proper line numbers.

@ordian
Copy link
Member

ordian commented Feb 22, 2022

BTW, do we already have some example flamegraphs or any other data that this generates? I'm curious how it'll handle our codebase compared to my profiler, especially whether it'll be able to gather full stack traces and whether it can properly demangle everything and decode inline frames along with proper line numbers.

(required vpn): https://github.com/paritytech/devops/issues/1221#issuecomment-1034150974

@drahnr
Copy link
Contributor Author

drahnr commented Feb 22, 2022

bot merge

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants