From b0f2651d4c0ca6bce3f82c5509aa6a771d3c27bd Mon Sep 17 00:00:00 2001 From: zhengziyi Date: Mon, 2 Dec 2024 14:40:04 +0800 Subject: [PATCH 1/2] Increase the default MAX_DURATION of async-profiler config --- .../org/apache/skywalking/apm/agent/core/conf/Config.java | 4 ++-- apm-sniffer/config/agent.config | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/Config.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/Config.java index fe2b7448e1..373ff40a0d 100755 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/Config.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/Config.java @@ -262,9 +262,9 @@ public static class AsyncProfiler { /** * Max execution time(second) for the Async Profiler. The task will be stopped even if a longer time is specified. - * default 10min. + * default 20min. */ - public static int MAX_DURATION = 600; + public static int MAX_DURATION = 1200; /** * Path for the JFR outputs from the Async Profiler. diff --git a/apm-sniffer/config/agent.config b/apm-sniffer/config/agent.config index 0ceb658627..695e47349f 100755 --- a/apm-sniffer/config/agent.config +++ b/apm-sniffer/config/agent.config @@ -166,8 +166,8 @@ profile.dump_max_stack_depth=${SW_AGENT_PROFILE_DUMP_MAX_STACK_DEPTH:500} profile.snapshot_transport_buffer_size=${SW_AGENT_PROFILE_SNAPSHOT_TRANSPORT_BUFFER_SIZE:4500} # If true, async profiler will be enabled when user creates a new async profiler task. If false, it will be disabled. The default value is true. asyncprofiler.active=${SW_AGENT_ASYNC_PROFILER_ACTIVE:true} -# Max execution time(second) for the Async Profiler. The task will be stopped even if a longer time is specified. default 10min. -asyncprofiler.max_duration=${SW_AGENT_ASYNC_PROFILER_MAX_DURATION:600} +# Max execution time(second) for the Async Profiler. The task will be stopped even if a longer time is specified. default 20min. +asyncprofiler.max_duration=${SW_AGENT_ASYNC_PROFILER_MAX_DURATION:1200} # Path for the JFR outputs from the Async Profiler. If the parameter is not empty, the file will be created in the specified directory, otherwise the Files.createTemp method will be used to create the file. asyncprofiler.output_path=${SW_AGENT_ASYNC_PROFILER_OUTPUT_PATH:} # If true, the agent collects and reports metrics to the backend. From 63b49035736803bbec55d48efcfe36fe960e5ecf Mon Sep 17 00:00:00 2001 From: zhengziyi Date: Mon, 2 Dec 2024 14:46:28 +0800 Subject: [PATCH 2/2] fix: Reduce memory allocation when sending jfr --- .../apm/agent/core/asyncprofiler/AsyncProfilerDataSender.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/asyncprofiler/AsyncProfilerDataSender.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/asyncprofiler/AsyncProfilerDataSender.java index 46a25c4cc2..be5af4c360 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/asyncprofiler/AsyncProfilerDataSender.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/asyncprofiler/AsyncProfilerDataSender.java @@ -100,6 +100,7 @@ public void sendData(AsyncProfilerTask task, File dumpFile) throws IOException, GRPC_UPSTREAM_TIMEOUT, TimeUnit.SECONDS ).collect(new ClientResponseObserver() { ClientCallStreamObserver requestStream; + final byte[] buf = new byte[DATA_CHUNK_SIZE]; @Override public void beforeStart(ClientCallStreamObserver requestStream) { @@ -111,7 +112,6 @@ public void onNext(AsyncProfilerCollectionResponse value) { if (AsyncProfilingStatus.TERMINATED_BY_OVERSIZE.equals(value.getType())) { LOGGER.warn("JFR is too large to be received by the oap server"); } else { - byte[] buf = new byte[DATA_CHUNK_SIZE]; try { int bytesRead; while ((bytesRead = fileInputStream.read(buf)) != -1) {