Skip to content

Commit 9137875

Browse files
Merge pull request #1504 from kakkoyun/add_flag_to_disable_jit_sym
symbolizer: Add flag to disable JIT symbolization
2 parents c7e62ef + 66c5021 commit 9137875

File tree

4 files changed

+23
-4
lines changed

4 files changed

+23
-4
lines changed

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ $(OUT_BIN_DEBUG): libbpf $(filter-out *_test.go,$(GO_SRC)) go/deps | $(OUT_DIR)
123123

124124
.PHONY: build-dyn
125125
build-dyn: $(OUT_BPF) libbpf
126-
$(GO_ENV) CGO_CFLAGS="$(CGO_CFLAGS_DYN)" CGO_LDFLAGS="$(CGO_LDFLAGS_DYN)" $(GO) build $(SANITIZERS) $(GO_BUILD_FLAGS) -o $(OUT_DIR)/parca-agent-dyn ./cmd/parca-agent
126+
$(GO_ENV) CGO_CFLAGS="$(CGO_CFLAGS_DYN)" CGO_LDFLAGS="$(CGO_LDFLAGS_DYN)" $(GO) build $(SANITIZERS) $(GO_BUILD_FLAGS) -o $(OUT_DIR)/parca-agent ./cmd/parca-agent
127127

128128
$(OUT_BIN_EH_FRAME): go/deps
129129
find dist -exec touch -t 202101010000.00 {} +
@@ -312,9 +312,10 @@ internal/pprof:
312312
rm -rf tmp
313313

314314
# other artifacts:
315-
$(OUT_DIR)/help.txt: $(OUT_BIN)
315+
$(OUT_DIR)/help.txt:
316316
# The default value of --node is dynamic and depends on the current host's name
317317
# so we replace it with something static.
318+
rm -f tmp/help.txt
318319
$(OUT_BIN) --help | sed 's/--node=".*" */--node="hostname" /' >$@
319320

320321
DOC_VERSION := "latest"

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ Flags:
6161
--log-format="logfmt" Configure if structured logging as JSON or as
6262
logfmt
6363
--http-address=":7071" Address to bind HTTP server to.
64-
--node="hostname" The name of the node that the process is
64+
--node="hostname"
65+
The name of the node that the process is
6566
running on. If on Kubernetes, this must match
6667
the Kubernetes node name.
6768
--config-path="" Path to config file.
@@ -115,6 +116,7 @@ Flags:
115116
--debuginfo-upload-timeout-duration=2m
116117
The timeout duration to cancel upload
117118
requests.
119+
--symbolizer-jit-disable Disable JIT symbolization.
118120
--dwarf-unwinding-disable Do not unwind using .eh_frame information.
119121
--dwarf-unwinding-use-polling
120122
Poll procfs to generate the unwind

cmd/parca-agent/main.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ type flags struct {
107107
LocalStore FlagsLocalStore `embed:"" prefix:"local-store-"`
108108
RemoteStore FlagsRemoteStore `embed:"" prefix:"remote-store-"`
109109
Debuginfo FlagsDebuginfo `embed:"" prefix:"debuginfo-"`
110+
Symbolizer FlagsSymbolizer `embed:"" prefix:"symbolizer-"`
110111
DWARFUnwinding FlagsDWARFUnwinding `embed:"" prefix:"dwarf-unwinding-"`
111112

112113
Hidden FlagsHidden `embed:"" prefix:"" hidden:""`
@@ -158,6 +159,11 @@ type FlagsDebuginfo struct {
158159
UploadTimeoutDuration time.Duration `default:"2m" help:"The timeout duration to cancel upload requests."`
159160
}
160161

162+
// FlagsSymbolizer contains flags to configure symbolization.
163+
type FlagsSymbolizer struct {
164+
JITDisable bool `kong:"help='Disable JIT symbolization.'"`
165+
}
166+
161167
// FlagsDWARFUnwinding contains flags to configure DWARF unwinding.
162168
type FlagsDWARFUnwinding struct {
163169
Disable bool `kong:"help='Do not unwind using .eh_frame information.'"`
@@ -473,6 +479,7 @@ func run(logger log.Logger, reg *prometheus.Registry, flags flags) error {
473479
perf.NewCache(logger),
474480
ksym.NewKsymCache(logger, reg),
475481
vdsoCache,
482+
flags.Symbolizer.JITDisable,
476483
),
477484
process.NewMappingFileCache(logger),
478485
objectfile.NewCache(20, flags.Profiling.Duration),

pkg/symbol/symbol.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,19 @@ type PerfCache interface {
4040
type Symbolizer struct {
4141
logger log.Logger
4242

43+
disableJIT bool
44+
4345
perfCache PerfCache
4446
ksymCache SymbolCache
4547
vdsoCache *vdso.Cache
4648
}
4749

48-
func NewSymbolizer(logger log.Logger, perfCache PerfCache, ksymCache SymbolCache, vdsoCache *vdso.Cache) *Symbolizer {
50+
func NewSymbolizer(logger log.Logger, perfCache PerfCache, ksymCache SymbolCache, vdsoCache *vdso.Cache, disableJIT bool) *Symbolizer {
4951
return &Symbolizer{
5052
logger: logger,
5153

54+
disableJIT: disableJIT,
55+
5256
perfCache: perfCache,
5357
ksymCache: ksymCache,
5458
vdsoCache: vdsoCache,
@@ -90,6 +94,11 @@ func (s *Symbolizer) Symbolize(prof *profiler.Profile) error {
9094
}
9195
}
9296

97+
// JIT symbolization is disabled, so we can skip the rest.
98+
if s.disableJIT {
99+
return result.ErrorOrNil()
100+
}
101+
93102
pid := prof.ID.PID
94103
userJITedFunctions, err := s.resolveJITedFunctions(pid, prof.UserLocations)
95104
if err != nil {

0 commit comments

Comments
 (0)