Class ProfileServlet

java.lang.Object
javax.servlet.GenericServlet
javax.servlet.http.HttpServlet
org.apache.hadoop.http.ProfileServlet
All Implemented Interfaces:
Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

@Private public class ProfileServlet extends javax.servlet.http.HttpServlet
Servlet that runs async-profiler as web-endpoint.

Following options from async-profiler can be specified as query paramater. // -e event profiling event: cpu|alloc|lock|cache-misses etc. // -d duration run profiling for 'duration' seconds (integer) // -i interval sampling interval in nanoseconds (long) // -j jstackdepth maximum Java stack depth (integer) // -b bufsize frame buffer size (long) // -t profile different threads separately // -s simple class names instead of FQN // -o fmt[,fmt...] output format: summary|traces|flat|collapsed|svg|tree|jfr|html // --width px SVG width pixels (integer) // --height px SVG frame height pixels (integer) // --minwidth px skip frames smaller than px (double) // --reverse generate stack-reversed FlameGraph / Call tree

Example: If Namenode http address is localhost:9870, and ResourceManager http address is localhost:8088, ProfileServlet running with async-profiler setup can be accessed with http://localhost:9870/prof and http://localhost:8088/prof for Namenode and ResourceManager processes respectively. Deep dive into some params: - To collect 10 second CPU profile of current process i.e. Namenode (returns FlameGraph svg) curl "http://localhost:9870/prof" - To collect 10 second CPU profile of pid 12345 (returns FlameGraph svg) curl "http://localhost:9870/prof?pid=12345" (For instance, provide pid of Datanode) - To collect 30 second CPU profile of pid 12345 (returns FlameGraph svg) curl "http://localhost:9870/prof?pid=12345&duration=30" - To collect 1 minute CPU profile of current process and output in tree format (html) curl "http://localhost:9870/prof?output=tree&duration=60" - To collect 10 second heap allocation profile of current process (returns FlameGraph svg) curl "http://localhost:9870/prof?event=alloc" - To collect lock contention profile of current process (returns FlameGraph svg) curl "http://localhost:9870/prof?event=lock"

Following event types are supported (default is 'cpu') (NOTE: not all OS'es support all events) // Perf events: // cpu // page-faults // context-switches // cycles // instructions // cache-references // cache-misses // branches // branch-misses // bus-cycles // L1-dcache-load-misses // LLC-load-misses // dTLB-load-misses // mem:breakpoint // trace:tracepoint // Java events: // alloc // lock

See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    doGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
     

    Methods inherited from class javax.servlet.http.HttpServlet

    doDelete, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service, service

    Methods inherited from class javax.servlet.GenericServlet

    destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, init, log, log

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ProfileServlet

      public ProfileServlet()
  • Method Details

    • doGet

      protected void doGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws IOException
      Overrides:
      doGet in class javax.servlet.http.HttpServlet
      Throws:
      IOException