drop use of CGO in profiler core#628
Conversation
dff06f9 to
bb25a13
Compare
| V8LineDeltaMask = C.V8_LINE_DELTA_MASK | ||
| ) | ||
|
|
||
| var MetricsTranslation = []metrics.MetricID{ |
There was a problem hiding this comment.
This brings the awkward dependency on metrics package, and has implications on metrics to not depend on libpf (which depends on support).
| var ( | ||
| // prevTimestamp holds the timestamp of the buffered metrics | ||
| prevTimestamp libpf.UnixTime32 | ||
| prevTimestamp uint32 |
There was a problem hiding this comment.
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.
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.
| 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.
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.
| enableSampling := false | ||
| var probProfilingStatus = probProfilingDisable | ||
|
|
||
| //nolint:gosec |
There was a problem hiding this comment.
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.
| var ( | ||
| // prevTimestamp holds the timestamp of the buffered metrics | ||
| prevTimestamp libpf.UnixTime32 | ||
| prevTimestamp uint32 |
There was a problem hiding this comment.
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