Skip to content

Commit 3afa56a

Browse files
author
Pete Stevenson
authored
Move pprof into shared sub-tree. (#1290)
Summary: We meed to move this code into a location that can be shared between `stirling` and `carnot`. Type of change: /kind cleanup Test Plan: The pprof export code will be integrated into a future diff. We have tested it locally using the `stirling_profiler` binary. Its test case will live inside of the (future work) `carnot` UDA that generates a profiling pprof protobuf for export. Signed-off-by: Pete Stevenson <jps@pixielabs.ai>
1 parent 33ad612 commit 3afa56a

3 files changed

Lines changed: 11 additions & 14 deletions

File tree

src/stirling/source_connectors/perf_profiler/pprof/BUILD.bazel renamed to src/shared/pprof/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
load("@rules_cc//cc:defs.bzl", "cc_proto_library")
1818
load("//bazel:pl_build_system.bzl", "pl_cc_library")
1919

20-
package(default_visibility = ["//src/stirling:__subpackages__"])
20+
package(default_visibility = ["//src:__subpackages__"])
2121

2222
cc_proto_library(
2323
name = "pprof_proto_cc",

src/stirling/source_connectors/perf_profiler/pprof/pprof.cc renamed to src/shared/pprof/pprof.cc

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,21 @@
1616
* SPDX-License-Identifier: Apache-2.0
1717
*/
1818

19-
#include "src/stirling/source_connectors/perf_profiler/pprof/pprof.h"
20-
21-
#include <gflags/gflags.h>
19+
#include "src/shared/pprof/pprof.h"
2220

2321
#include <absl/strings/str_split.h>
2422
#include <vector>
2523

26-
DECLARE_uint32(stirling_profiler_stack_trace_sample_period_ms);
27-
2824
namespace px {
29-
namespace stirling {
25+
namespace shared {
3026

31-
PProfProfile CreatePProfProfile(const uint32_t num_cpus, const histo_t& histo) {
27+
PProfProfile CreatePProfProfile(const uint32_t num_cpus, const uint32_t period_ms,
28+
const absl::flat_hash_map<std::string, uint64_t>& histo) {
3229
// Info on the pprof proto format:
3330
// https://github.com/google/pprof/blob/main/proto/profile.proto
3431

32+
// period_ms is the stack trace sampling period used by the eBPF stack trace sampling probe.
3533
// period_ns will be used when populating the nanos count.
36-
const uint64_t period_ms = FLAGS_stirling_profiler_stack_trace_sample_period_ms;
3734
const uint64_t period_ns = period_ms * 1000 * 1000;
3835

3936
// Tracks which strings have been inserted into the profile.
@@ -138,5 +135,5 @@ PProfProfile CreatePProfProfile(const uint32_t num_cpus, const histo_t& histo) {
138135
return profile;
139136
}
140137

141-
} // namespace stirling
138+
} // namespace shared
142139
} // namespace px

src/stirling/source_connectors/perf_profiler/pprof/pprof.h renamed to src/shared/pprof/pprof.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@
2525
#include "proto/profile.pb.h"
2626

2727
namespace px {
28-
namespace stirling {
28+
namespace shared {
2929

3030
using PProfProfile = ::perftools::profiles::Profile;
31-
using histo_t = absl::flat_hash_map<std::string, uint64_t>;
3231

3332
// https://github.com/google/pprof/blob/main/proto/profile.proto
34-
PProfProfile CreatePProfProfile(const uint32_t num_cpus, const histo_t& histo);
33+
PProfProfile CreatePProfProfile(const uint32_t num_cpus, const uint32_t period_ms,
34+
const absl::flat_hash_map<std::string, uint64_t>& histo);
3535

36-
} // namespace stirling
36+
} // namespace shared
3737
} // namespace px

0 commit comments

Comments
 (0)