Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HADOOP-18055. Async Profiler endpoint for Hadoop daemons #3824

Merged
merged 6 commits into from Jan 6, 2022

Conversation

virajjasani
Copy link
Contributor

@virajjasani virajjasani commented Dec 22, 2021

Description of PR

Async profiler (https://github.com/jvm-profiling-tools/async-profiler) is a low overhead sampling profiler for Java that does not suffer from Safepoint bias problem. It features HotSpot-specific APIs to collect stack traces and to track memory allocations. The profiler works with OpenJDK, Oracle JDK and other Java runtimes based on the HotSpot JVM.
Async profiler can also profile heap allocations, lock contention, and HW performance counters in addition to CPU.

This PR provides Async profiler endpoint for Hadoop daemons.

More analysis on CPU and memory overhead:

  1. Measure and document overhead async-profiler/async-profiler#14
  2. CPU profiling Memory and CPU overhead async-profiler/async-profiler#131

How was this patch tested?

Locally. Screenshots:
Screenshot 2021-12-22 at 6 54 07 PM

Screenshot 2021-12-22 at 6 55 00 PM

Screenshot 2021-12-22 at 6 55 44 PM

Screenshot 2021-12-22 at 6 56 44 PM

Screenshot 2021-12-22 at 6 57 45 PM

Screenshot 2021-12-22 at 6 58 57 PM

Screenshot 2021-12-22 at 6 59 34 PM

Screenshot 2021-12-22 at 7 01 49 PM

Screenshot 2021-12-22 at 7 02 59 PM

Screenshot 2021-12-22 at 7 03 15 PM

Screenshot 2021-12-22 at 7 04 01 PM

Screenshot 2021-12-22 at 7 07 09 PM

Screenshot 2021-12-22 at 7 07 41 PM

Screenshot 2021-12-22 at 7 37 16 PM

For code changes:

  • Does the title or this PR starts with the corresponding JIRA issue id (e.g. 'HADOOP-17799. Your PR title ...')?

@hadoop-yetus

This comment has been minimized.

@virajjasani
Copy link
Contributor Author

@aajisaka @jojochuang @tasanuma Could you please take a look?

@hadoop-yetus

This comment has been minimized.

@virajjasani
Copy link
Contributor Author

Requesting review from @ayushtkn @liuml07 as well, nothing urgent, as per your convenience.

@aajisaka aajisaka self-requested a review December 24, 2021 08:45
@aajisaka
Copy link
Member

Thank you @virajjasani for your patch. This feature looks very helpful for us to investigate the root cause of some performance issues. I'll build and deploy Hadoop cluster and test this feature.

Now I have one comment: We need to add an additional access control for this servlet like ConfServlet. In addition, we need to update the document of hadoop.security.instrumentation.requires.admin.

@Override
protected void doGet(final HttpServletRequest req, final HttpServletResponse resp)
throws IOException {
if (!HttpServer2.isInstrumentationAccessAllowed(getServletContext(), req, resp)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @aajisaka. I have added isInstrumentationAccessAllowed here but let me also add it to ProfileOutputServlet so that even before the url redirection takes place, user will get SC_UNAUTHORIZED response.

Comment on lines 58 to 60
* If Namenode http address is 9870, and ResourceManager http address is 8088,
* ProfileServlet running with async-profiler setup can be accessed with
* http://localhost:9870/prof and http://localhost:8088/prof
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we comment the NameNode and ResourceManager is running on localhost?

@hadoop-yetus

This comment has been minimized.

@hadoop-yetus

This comment has been minimized.

@hadoop-yetus
Copy link

🎊 +1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 0m 45s Docker mode activated.
_ Prechecks _
+1 💚 dupname 0m 1s No case conflicting files found.
+0 🆗 codespell 0m 0s codespell was not available.
+0 🆗 markdownlint 0m 0s markdownlint was not available.
+1 💚 @author 0m 0s The patch does not contain any @author tags.
+1 💚 test4tests 0m 0s The patch appears to include 1 new or modified test files.
_ trunk Compile Tests _
+0 🆗 mvndep 12m 55s Maven dependency ordering for branch
+1 💚 mvninstall 21m 41s trunk passed
+1 💚 compile 22m 19s trunk passed with JDK Ubuntu-11.0.11+9-Ubuntu-0ubuntu2.20.04
+1 💚 compile 19m 24s trunk passed with JDK Private Build-1.8.0_292-8u292-b10-0ubuntu1~20.04-b10
+1 💚 checkstyle 3m 41s trunk passed
+1 💚 mvnsite 4m 1s trunk passed
+1 💚 javadoc 3m 20s trunk passed with JDK Ubuntu-11.0.11+9-Ubuntu-0ubuntu2.20.04
+1 💚 javadoc 3m 45s trunk passed with JDK Private Build-1.8.0_292-8u292-b10-0ubuntu1~20.04-b10
+0 🆗 spotbugs 0m 42s branch/hadoop-project no spotbugs output file (spotbugsXml.xml)
+1 💚 shadedclient 22m 13s branch has no errors when building and testing our client artifacts.
_ Patch Compile Tests _
+0 🆗 mvndep 0m 30s Maven dependency ordering for patch
+1 💚 mvninstall 2m 2s the patch passed
+1 💚 compile 21m 24s the patch passed with JDK Ubuntu-11.0.11+9-Ubuntu-0ubuntu2.20.04
+1 💚 javac 21m 24s the patch passed
+1 💚 compile 19m 26s the patch passed with JDK Private Build-1.8.0_292-8u292-b10-0ubuntu1~20.04-b10
+1 💚 javac 19m 26s the patch passed
+1 💚 blanks 0m 0s The patch has no blanks issues.
+1 💚 checkstyle 3m 32s the patch passed
+1 💚 mvnsite 3m 59s the patch passed
+1 💚 xml 0m 2s The patch has no ill-formed XML file.
+1 💚 javadoc 3m 18s the patch passed with JDK Ubuntu-11.0.11+9-Ubuntu-0ubuntu2.20.04
+1 💚 javadoc 3m 46s the patch passed with JDK Private Build-1.8.0_292-8u292-b10-0ubuntu1~20.04-b10
+0 🆗 spotbugs 0m 38s hadoop-project has no data from spotbugs
+1 💚 shadedclient 20m 55s patch has no errors when building and testing our client artifacts.
_ Other Tests _
+1 💚 unit 0m 37s hadoop-project in the patch passed.
+1 💚 unit 17m 32s hadoop-common in the patch passed.
+1 💚 unit 3m 46s hadoop-kms in the patch passed.
+1 💚 unit 6m 18s hadoop-hdfs-httpfs in the patch passed.
+1 💚 asflicense 1m 1s The patch does not generate ASF License warnings.
237m 7s
Subsystem Report/Notes
Docker ClientAPI=1.41 ServerAPI=1.41 base: https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-3824/5/artifact/out/Dockerfile
GITHUB PR #3824
Optional Tests dupname asflicense compile javac javadoc mvninstall mvnsite unit shadedclient spotbugs checkstyle codespell xml markdownlint
uname Linux fa378abdb56f 4.15.0-58-generic #64-Ubuntu SMP Tue Aug 6 11:12:41 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality dev-support/bin/hadoop.sh
git revision trunk / 8501c77
Default Java Private Build-1.8.0_292-8u292-b10-0ubuntu1~20.04-b10
Multi-JDK versions /usr/lib/jvm/java-11-openjdk-amd64:Ubuntu-11.0.11+9-Ubuntu-0ubuntu2.20.04 /usr/lib/jvm/java-8-openjdk-amd64:Private Build-1.8.0_292-8u292-b10-0ubuntu1~20.04-b10
Test Results https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-3824/5/testReport/
Max. process+thread count 1293 (vs. ulimit of 5500)
modules C: hadoop-project hadoop-common-project/hadoop-common hadoop-common-project/hadoop-kms hadoop-hdfs-project/hadoop-hdfs-httpfs U: .
Console output https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-3824/5/console
versions git=2.25.1 maven=3.6.3 spotbugs=4.2.2
Powered by Apache Yetus 0.14.0-SNAPSHOT https://yetus.apache.org

This message was automatically generated.

Copy link
Contributor

@jojochuang jojochuang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it support async profiler 1.x and 2.x? Better to document that somewhere.

HttpURLConnection conn =
(HttpURLConnection) new URL(baseUrl, "/prof").openConnection();
assertEquals("GET", conn.getHeaderField(ProfileServlet.ACCESS_CONTROL_ALLOW_METHODS));
assertNotNull(conn.getHeaderField(ProfileServlet.ACCESS_CONTROL_ALLOW_ORIGIN));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it be a good idea to call conn.disconnect() to clean up?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

private static final int DEFAULT_DURATION_SECONDS = 10;
private static final AtomicInteger ID_GEN = new AtomicInteger(0);

static final String OUTPUT_DIR = System.getProperty("java.io.tmpdir") + "/prof-output";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because the ProfileServlet is used by several systems (Ozone, HBase, Hive), I would suggest to make the default output dir specific to Hadoop

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(related: HDDS-5387)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, updated. (good to know Ozone also supports this)

@virajjasani
Copy link
Contributor Author

does it support async profiler 1.x and 2.x? Better to document that somewhere.

Yes, updated AsyncProfilerServlet.md. Thanks

@hadoop-yetus
Copy link

🎊 +1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 0m 55s Docker mode activated.
_ Prechecks _
+1 💚 dupname 0m 0s No case conflicting files found.
+0 🆗 codespell 0m 1s codespell was not available.
+0 🆗 markdownlint 0m 1s markdownlint was not available.
+1 💚 @author 0m 0s The patch does not contain any @author tags.
+1 💚 test4tests 0m 0s The patch appears to include 1 new or modified test files.
_ trunk Compile Tests _
+0 🆗 mvndep 12m 52s Maven dependency ordering for branch
+1 💚 mvninstall 24m 28s trunk passed
+1 💚 compile 24m 5s trunk passed with JDK Ubuntu-11.0.11+9-Ubuntu-0ubuntu2.20.04
+1 💚 compile 20m 28s trunk passed with JDK Private Build-1.8.0_292-8u292-b10-0ubuntu1~20.04-b10
+1 💚 checkstyle 3m 52s trunk passed
+1 💚 mvnsite 3m 27s trunk passed
+1 💚 javadoc 2m 41s trunk passed with JDK Ubuntu-11.0.11+9-Ubuntu-0ubuntu2.20.04
+1 💚 javadoc 3m 11s trunk passed with JDK Private Build-1.8.0_292-8u292-b10-0ubuntu1~20.04-b10
+0 🆗 spotbugs 0m 32s branch/hadoop-project no spotbugs output file (spotbugsXml.xml)
+1 💚 shadedclient 23m 25s branch has no errors when building and testing our client artifacts.
_ Patch Compile Tests _
+0 🆗 mvndep 0m 23s Maven dependency ordering for patch
+1 💚 mvninstall 1m 54s the patch passed
+1 💚 compile 23m 9s the patch passed with JDK Ubuntu-11.0.11+9-Ubuntu-0ubuntu2.20.04
+1 💚 javac 23m 9s the patch passed
+1 💚 compile 20m 30s the patch passed with JDK Private Build-1.8.0_292-8u292-b10-0ubuntu1~20.04-b10
+1 💚 javac 20m 30s the patch passed
+1 💚 blanks 0m 0s The patch has no blanks issues.
+1 💚 checkstyle 3m 49s the patch passed
+1 💚 mvnsite 3m 23s the patch passed
+1 💚 xml 0m 3s The patch has no ill-formed XML file.
+1 💚 javadoc 2m 38s the patch passed with JDK Ubuntu-11.0.11+9-Ubuntu-0ubuntu2.20.04
+1 💚 javadoc 3m 8s the patch passed with JDK Private Build-1.8.0_292-8u292-b10-0ubuntu1~20.04-b10
+0 🆗 spotbugs 0m 29s hadoop-project has no data from spotbugs
+1 💚 shadedclient 23m 27s patch has no errors when building and testing our client artifacts.
_ Other Tests _
+1 💚 unit 0m 27s hadoop-project in the patch passed.
+1 💚 unit 17m 43s hadoop-common in the patch passed.
+1 💚 unit 3m 36s hadoop-kms in the patch passed.
+1 💚 unit 8m 17s hadoop-hdfs-httpfs in the patch passed.
+1 💚 asflicense 0m 49s The patch does not generate ASF License warnings.
246m 19s
Subsystem Report/Notes
Docker ClientAPI=1.41 ServerAPI=1.41 base: https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-3824/6/artifact/out/Dockerfile
GITHUB PR #3824
Optional Tests dupname asflicense compile javac javadoc mvninstall mvnsite unit shadedclient spotbugs checkstyle codespell xml markdownlint
uname Linux 40466c6b26ec 4.15.0-163-generic #171-Ubuntu SMP Fri Nov 5 11:55:11 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality dev-support/bin/hadoop.sh
git revision trunk / 49bff7c
Default Java Private Build-1.8.0_292-8u292-b10-0ubuntu1~20.04-b10
Multi-JDK versions /usr/lib/jvm/java-11-openjdk-amd64:Ubuntu-11.0.11+9-Ubuntu-0ubuntu2.20.04 /usr/lib/jvm/java-8-openjdk-amd64:Private Build-1.8.0_292-8u292-b10-0ubuntu1~20.04-b10
Test Results https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-3824/6/testReport/
Max. process+thread count 1236 (vs. ulimit of 5500)
modules C: hadoop-project hadoop-common-project/hadoop-common hadoop-common-project/hadoop-kms hadoop-hdfs-project/hadoop-hdfs-httpfs U: .
Console output https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-3824/6/console
versions git=2.25.1 maven=3.6.3 spotbugs=4.2.2
Powered by Apache Yetus 0.14.0-SNAPSHOT https://yetus.apache.org

This message was automatically generated.

Copy link
Contributor

@jojochuang jojochuang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this one looks good to me.

@jojochuang jojochuang merged commit f64fda0 into apache:trunk Jan 6, 2022
HarshitGupta11 pushed a commit to HarshitGupta11/hadoop that referenced this pull request Nov 28, 2022
Reviewed-by: Akira Ajisaka <aajisaka@apache.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants