Skip to content

RFC: build the profiler with both release and debug tracers by default #232

Description

@tsint

The previous and related discussions were happening in #225.
Here is an analysis of the needs and issues people face:

Main Needs:

  1. Enable the debugging for the tracer at any time by the parameter to obtain more meaningful information without needing to recompile it.
  2. When the debugging is not needed, disable it by remove the parameter to run the profiler with optimal performance.
  3. If possible, integrate the BPF program of the profiler into third-party applications with the debug tracer to be enabled, and get valuable information in some way.

Main Issue:
When binary files are committed to the git repository, the storage space quickly increases with each commit.

My Solution:

  1. Build both the release and debug tracer by default, and enable or disable tracer debugging as needed.
  2. Publish a profiler with the debug tracer on a branch synchronized with the mainline, and tagged with a special label like v1.0.1-debug to make integration easy.

Implementation Steps:

  1. Modify the Makefile in the root directory, select different GO_TAGS and BPF program compilation commands based on the branch .
-GO_TAGS := osusergo,netgo
-EBPF_FLAGS :=
+ifneq (,$(findstring debug,$(BRANCH)))
+    GO_TAGS := osusergo,netgo
+    EBPF_FLAGS := fake-release
+else
+    GO_TAGS := osusergo,netgo,debugtracer
+    EBPF_FLAGS :=
+endif


-debug: GO_TAGS := $(GO_TAGS),debugtracer
-debug: EBPF_FLAGS += debug
-debug: all
  1. Modify the Makefile in the support/ebpf directory, and compile two versions of the tracer by default. If the debug tracer need to be released, compile only the debug version tracer and rename it as the release version tracer. By this way, third-party applications can use v1.0.1-debug to reference the debug version tracer.
-TRACER_NAME ?= tracer.ebpf.$(BUILD_TYPE).$(TARGET_ARCH)
+TRACER ?= tracer.ebpf.release.$(TARGET_ARCH)
+DEBUG_TRACER ?= tracer.ebpf.debug.$(TARGET_ARCH)
+
+TARGET ?= $(TRACER) $(DEBUG_TRACER)


-ifeq ($(BUILD_TYPE),debug)
-       TARGET_FLAGS+=$(DEBUG_FLAGS)
-endif


 SRCS := $(wildcard *.ebpf.c)
-OBJS := $(SRCS:.c=.$(BUILD_TYPE).$(TARGET_ARCH).o)
+OBJS := $(SRCS:.c=.release.$(TARGET_ARCH).o)
+DEBUG_OBJS := $(SRCS:.c=.debug.$(TARGET_ARCH).o)

-all: $(TRACER_NAME)
+all: $(TARGET)

-debug:
-       $(MAKE) BUILD_TYPE=debug
+fake-release:
+       $(MAKE) TARGET=$(DEBUG_TRACER)
+       mv $(DEBUG_TRACER) $(TRACER)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions