-
Notifications
You must be signed in to change notification settings - Fork 317
drop use of CGO in profiler core #628
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
Conversation
dff06f9
to
bb25a13
Compare
V8LineDeltaMask = C.V8_LINE_DELTA_MASK | ||
) | ||
|
||
var MetricsTranslation = []metrics.MetricID{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This brings the awkward dependency on metrics
package, and has implications on metrics
to not depend on libpf
(which depends on support
).
prevTimestamp libpf.UnixTime32 | ||
prevTimestamp uint32 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is to avoid circular dependency of metrics
-> libpf
-> support
-> metrics
. This is because of moving the metrics mappings to the generated file in support (to avoid adding generated files).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could also move UnixTime32
to times
or util
package but as we don't use the MarshalJSON
method here so it's probably not worth it just for this case.
@@ -555,7 +555,7 @@ typedef struct Trace { | |||
// Monotonic kernel time in nanosecond precision. | |||
u64 ktime; | |||
// The current COMM of the thread of this Trace. | |||
char comm[COMM_LEN]; | |||
u8 comm[COMM_LEN]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This and the above CustomLabel
change are due to arm64 and amd64 default char
differing on signedness and would cause the generated code check to fail on one or the other flavor due to inconsistent type.
It also greatly simplifies things to have this unconditionall u8
which maps to uint8
(and for which byte
is an alias). These are directly usable as []byte
.
@@ -1165,6 +1077,7 @@ func (t *Tracer) probabilisticProfile(interval time.Duration, threshold uint) { | |||
enableSampling := false | |||
var probProfilingStatus = probProfilingDisable | |||
|
|||
//nolint:gosec |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is to suppress lint warning on using non-secure random generator. This is ok here as this just for probability and not security related.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
prevTimestamp libpf.UnixTime32 | ||
prevTimestamp uint32 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could also move UnixTime32
to times
or util
package but as we don't use the MarshalJSON
method here so it's probably not worth it just for this case.
This removes usage of CGO in the ebpf-profiler core by creating a cgo generated alias type for needed types with ebpf.
fixes #511