beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yi...@apache.org
Subject [beam] branch master updated: Add google cloud heap profiling support to beam java sdk container
Date Fri, 06 Aug 2021 00:16:22 GMT
This is an automated email from the ASF dual-hosted git repository.

yichi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/beam.git


The following commit(s) were added to refs/heads/master by this push:
     new 0ac5480  Add google cloud heap profiling support to beam java sdk container
     new 10e3e57  Merge pull request #15288 from andyxiexu/java-sdk
0ac5480 is described below

commit 0ac54802ed07d962fde573208789d1106deb7de8
Author: Andy Xu <andyxu@google.com>
AuthorDate: Thu Aug 5 13:37:05 2021 -0700

    Add google cloud heap profiling support to beam java sdk container
---
 sdks/java/container/boot.go | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/sdks/java/container/boot.go b/sdks/java/container/boot.go
index 2c029e5..d0f108c 100644
--- a/sdks/java/container/boot.go
+++ b/sdks/java/container/boot.go
@@ -48,6 +48,13 @@ var (
 	semiPersistDir    = flag.String("semi_persist_dir", "/tmp", "Local semi-persistent directory
(optional).")
 )
 
+const (
+	enableGoogleCloudProfilerOption     = "enable_google_cloud_profiler"
+	enableGoogleCloudHeapSamplingOption = "enable_google_cloud_heap_sampling"
+	googleCloudProfilerAgentBaseArgs    = "-agentpath:/opt/google_cloud_profiler/profiler_java_agent.so=-logtostderr,-cprof_service=%s,-cprof_service_version=%s"
+	googleCloudProfilerAgentHeapArgs    = googleCloudProfilerAgentBaseArgs + ",-cprof_enable_heap_sampling,-cprof_heap_sampling_interval=2097152"
+)
+
 func main() {
 	flag.Parse()
 	if *id == "" {
@@ -151,12 +158,18 @@ func main() {
 		"-cp", strings.Join(cp, ":"),
 	}
 
-	enableGoogleCloudProfiler := strings.Contains(options, "enable_google_cloud_profiler")
+	enableGoogleCloudProfiler := strings.Contains(options, enableGoogleCloudProfilerOption)
+	enableGoogleCloudHeapSampling := strings.Contains(options, enableGoogleCloudHeapSamplingOption)
 	if enableGoogleCloudProfiler {
 		if metadata := info.GetMetadata(); metadata != nil {
 			if jobName, nameExists := metadata["job_name"]; nameExists {
 				if jobId, idExists := metadata["job_id"]; idExists {
-					args = append(args, fmt.Sprintf("-agentpath:/opt/google_cloud_profiler/profiler_java_agent.so=-cprof_service=%s,-cprof_service_version=%s",
jobName, jobId))
+					if enableGoogleCloudHeapSampling {
+						args = append(args, fmt.Sprintf(googleCloudProfilerAgentHeapArgs, jobName, jobId))
+					} else {
+						args = append(args, fmt.Sprintf(googleCloudProfilerAgentBaseArgs, jobName, jobId))
+					}
+					log.Printf("Turning on Cloud Profiling. Profile heap: %t", enableGoogleCloudHeapSampling)
 				} else {
 					log.Println("Required job_id missing from metadata, profiling will not be enabled without
it.")
 				}

Mime
View raw message