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

[profiling] use internal Label instead of pprof::Label #454

Merged
merged 4 commits into from
May 28, 2024

Conversation

taegyunkim
Copy link
Contributor

@taegyunkim taegyunkim commented May 24, 2024

What does this PR do?

Resolves a TODO. Use internal::Label instead of pprof::Label to make it easier to fuzz test. Even though pprof::Label can also derive bolero_generator::TypeGenerator guarded by cfg(test), it would be best to keep internal things internal.
Also, this lets us use pprof::Label only when returning pprof.

Motivation

TODO

Additional Notes

Anything else we should know when reviewing?

How to test the change?

cargo nextest run

@github-actions github-actions bot added the profiling Relates to the profiling* modules. label May 24, 2024
@codecov-commenter
Copy link

codecov-commenter commented May 24, 2024

Codecov Report

Attention: Patch coverage is 93.75000% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 67.89%. Comparing base (633b0b0) to head (0593cd7).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #454      +/-   ##
==========================================
- Coverage   67.90%   67.89%   -0.02%     
==========================================
  Files         193      193              
  Lines       24651    24643       -8     
==========================================
- Hits        16740    16731       -9     
- Misses       7911     7912       +1     
Components Coverage Δ
crashtracker 19.34% <ø> (ø)
datadog-alloc 98.76% <ø> (ø)
data-pipeline 51.45% <ø> (ø)
data-pipeline-ffi 0.00% <ø> (ø)
ddcommon 85.24% <ø> (ø)
ddcommon-ffi 74.93% <ø> (ø)
ddtelemetry 56.09% <ø> (ø)
ipc 81.69% <ø> (ø)
profiling 78.04% <93.75%> (-0.05%) ⬇️
profiling-ffi 60.05% <ø> (ø)
serverless 0.00% <ø> (ø)
sidecar 37.89% <ø> (ø)
sidecar-ffi 0.00% <ø> (ø)
spawn-worker 54.98% <ø> (ø)
trace-mini-agent 69.12% <ø> (ø)
trace-normalization 97.79% <ø> (ø)
trace-obfuscation 95.74% <ø> (ø)
trace-protobuf 30.76% <ø> (ø)
trace-utils 79.66% <ø> (ø)

@taegyunkim taegyunkim marked this pull request as ready for review May 28, 2024 16:22
@taegyunkim taegyunkim requested a review from a team as a code owner May 28, 2024 16:22
@morrisonlevi
Copy link
Contributor

morrisonlevi commented May 28, 2024

I believe this means we can also remove StringId::new now, yes? It has a todo about this.

Copy link
Contributor

@danielsn danielsn left a comment

Choose a reason for hiding this comment

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

LGTM

.map(|res| res.map(pprof::Label::from)),
)
.chain(timestamp.map(|ts| Ok(Label::num(self.timestamp_key, ts.get(), None).into())))
.map(|l| self.get_label(*l).copied())
Copy link
Contributor

Choose a reason for hiding this comment

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

Thought: since Label is Copy, should get_label just return an owned object rather than a reference?

Copy link
Contributor

Choose a reason for hiding this comment

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

(not needed for this PR, but might be interesting to not bother taking Copy types by reference

Copy link
Contributor

Choose a reason for hiding this comment

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

I know for small types, yes, it's definitely preferred to work by-value instead of reference. I'm not sure what "small" means for Rust calling conventions, though. Is Label small?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Label has StringId, which is u32 and LabelValue.

pub struct Label {
key: StringId,
value: LabelValue,
}

LabelVale is an enum which can be

  • StringId, again u32
  • i64 and optional StringId

pub enum LabelValue {

label.get_key(),
match label.get_value() {
LabelValue::Str(str) => *str,
LabelValue::Num { .. } => StringId::ZERO,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this an error if this case is reached?

Copy link
Contributor Author

@taegyunkim taegyunkim May 28, 2024

Choose a reason for hiding this comment

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

I simply looked at impl From<&Label> for pprof::Label here.

impl From<&Label> for pprof::Label {
fn from(l: &Label) -> pprof::Label {
let key = l.key.to_raw_id();
match l.value {
LabelValue::Str(str) => Self {
key,
str: str.to_raw_id(),
num: 0,
num_unit: 0,
},
LabelValue::Num { num, num_unit } => Self {
key,
str: 0,
num,
num_unit: num_unit.map(StringId::into_raw_id).unwrap_or_default(),

I don't think this was treated as an error before this PR.

@taegyunkim taegyunkim changed the title use internal Label instead of pprof::Label [profiling] use internal Label instead of pprof::Label May 28, 2024
@taegyunkim taegyunkim merged commit d8a3c9a into main May 28, 2024
26 checks passed
@taegyunkim taegyunkim deleted the taegyunkim/upscaling-label-fix branch May 28, 2024 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
profiling Relates to the profiling* modules.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants