Skip to content

Bazel processes

Daemonitor discovers and monitors Bazel-related JVM and native processes across macOS, Linux, and Windows, tracking persistent workers, test processes, and sandboxed descendant subtrees beneath each BAZEL_SERVER.

  • Bazel Java: Java persistent workers (JavaBuilder, VanillaJavaBuilder) and JVM test runners.
  • Bazel Kotlin: rules_kotlin / KotlinBuilder persistent workers and disambiguation from Gradle Kotlin daemons.
  • Bazel native processes: Swift/native workers, native test executables, and sandboxed compiler actions rolled into server subtrees.

Recognized process types

Process type Display label Runtime Role
BAZEL_SERVER Bazel server JVM Persistent Bazel server (A-server.jar with --product_name=Bazel or --output_base=)
BAZEL_WORKER Bazel worker (toolchain-aware: Java worker, Kotlin worker, Swift worker) JVM, NATIVE, or UNKNOWN Persistent worker (--persistent_worker + Bazel worker marker)
BAZEL_TEST Bazel test JVM, NATIVE, or UNKNOWN BazelTestRunner, -Dbazel.test_suite=, test-setup.sh, or promoted native test leaf

Workspace, output base, and embedded JDK

For BAZEL_SERVER, Daemonitor extracts --workspace_directory= (falling back to cwd), --output_base=, and --install_base=.

  • Embedded JDK probing: Resolves <install_base>/embedded_tools/jdk so jcmd, jstat, and jinfo can probe the Bazel server even when no system JAVA_HOME is configured.
  • Server logs: Watches command.log and server/jvm.out under the server's --output_base.

Subtree rollups and double-counting prevention

Because Bazel spawns short-lived sandboxed actions (sandbox-exec, linux-sandbox, process-wrapper) and compilers beneath BAZEL_SERVER:

  • Pass 0 indexes the full OS process tree (up to depth 64) with parent.start <= child.start PID-reuse validation.
  • Unclassified Bazel descendants are sampled cheaply (RSS and CPU only—no JVM probes) and rolled into BAZEL_SERVER's inclusive SubtreeRSSMemoryMB, SubtreeCPUPercent, ActiveWorkerCount, and ActiveSandboxedActionCount.
  • Section summaries and resource aggregators (AggregateResources) use SubtreeRSSMemoryMB / SubtreeCPUPercent on BAZEL_SERVER and exclude visible children owned by that server (OwnerPID + OwnerStartTimeMs) to prevent double-counting.

Build Event Protocol (BEP) and JSON profiles

  • Passive BEP discovery: When a bazel / bazelisk client specifies --build_event_json_file or --build_event_binary_file, daemonitor-cored parses the BEP stream into structured BazelBuildDetails (memory, timing, actions, workers, worker_pools, tests, test_totals, diagnostics) stored in bazel_build_details.
  • JSON trace profiles: cored/internal/bazelprofile can also ingest Bazel's default gzipped JSON trace profiles without requiring BEP flags.
  • Incarnation-scoped build windows: Peak/average RSS and CPU are computed per Bazel server incarnation (ResolveBazelServerIncarnation) without double-counting workers.

Filtering Bazel workloads in CLI

# All Bazel processes
daemonitor-cli ps --ecosystem bazel

# Detailed JSON snapshot for Bazel processes
daemonitor-cli ps --ecosystem bazel --json