Previous Topic

Next Topic

Book Contents

Book Index

Starting Remote Profiling

It's not always possible to run the Profiler Frontend on the same host as the program to be profiled. The frontend consumes additional system resources besides the application it profiles, so this could make the profiling impossible on devices with thin resources. For that reason, mBProfiler enables profiling not only of locally running applications but also of remote ones.

Remote Java Application Launch Configuration

You can profile applications residing on a remote JVM using a Remote Java Application launch configuration. You have to supply connection properties in the Connect tab, as well as configure if needed the properties into the mBProfiler and Triggers tabs. The rest of the launch properties are the same as in the other launch configurations.

To create a Remote Java Application profile configuration:

  1. Open the Profile Configurations dialog:
  2. In the Profile Configurations dialog, right-click the Remote Java Application configuration type and select New. A profile configuration will be created.
  3. Go to the mBProfiler configuration tab and fill in the profiling tasks as described in the Configuring General and Auto-Start Session Settings guide.
  4. Go to Connection tab to configure the settings for connection with the remote process being profiled.

    In the Connection Type field allows to choose how you will connect to the remote JVM.

  5. If needed, define profiling triggers in the Triggers configuration tab as described in the Defining Profiling Triggers document.
  6. Depending on the application type provide other launch information if required, such as the workspace project holding the application source files, etc.
  7. Click Apply to save the changes.

Providing a Profiler Agent onto the Remote System

This feature is supported only when mBProfiler is started as a standalone application.

To be able to perform remote profiling, first you need to equip the remote application's host with a Profiler Agent. To do that, copy the Profiler Agent intended for the corresponding OS on the target host. Then add the location of the agent's directory to the PATH environment variable for Windows OS, to the LD_LIBRARY_PATH one for Linux and Solaris, or to its analogue in the OS in use. Modifications of the agent adapted to different OSes are available in the plugins/com.prosyst.mbs.mbprofiler_x_x_x/native installation directory.

Enabling Byte Code Modification for JVMTI

This feature is supported only when mBProfiler is started as a standalone application.

In certain cases, using mBProfiler on top of JVMTI requires additional byte code modification on the target host. To enable the JVM load the modification mechanism, compliant with mBProfiler, execute one of the following tasks:

Attaching to a Remote VM

To attach mBProfiler to a remote JVM:

Prerequisite: On the profiled host make sure that the JVM is supported by mBProfiler as well as that the profiler agent is suitable for the underlying platform, such as OS, JVMTI profiling interface, etc.

  1. Run the application you want to profile remotely using the relevant JVM-specific command line options to:
  2. Create a Remote Java Application launch configuration (see "Remote Java Application Launch Configuration" section at the top of the page) and choose the Standard (Socket Attach) as connection type in the Connect tab.
  3. In the Connection Properties pane specify the host address and the port of the remote JVM process.
  4. Finally, click Profile to start profiling.

Once profiling is launched, you can control its execution from the Profile view.

Listening to a Remote VM

When listening to a remote JVM, mBProfiler actually waits for the remote JVM to connect to it and then starts displaying the profiling information. To listen to a remote VM:

Prerequisite: On the profiled host make sure that the JVM is supported by mBProfiler as well as that the profiler agent is suitable for the underlying platform.

  1. In Eclipse, create a Remote Java Application launch configuration (see "Remote Java Application Launch Configuration" section at the top of the page) and choose the Standard (Socket Listen) connection type in the Connect tab.
  2. In the Connection Properties pane, enter the port on which mBProfiler will listen to the remote VM.
  3. Finally, click Profile to start listening.
  4. Run the application you want to profile remotely using the relevant JVM-specific command line options to:

Once profiling is launched, you can control its execution from the Profile view.

Adding the Profiler API to the Java Process

mBProfiler provides a special API, which can be used to launch certain profiling actions such as memory or CPU profiling during the execution of a method. This API is used by the profiler agent itself as well. Hence, to have the complete set of mBProfiler features active, make sure that the Java boot classpath contains a path to com.prosyst.mbs.mbprofiler.api.jar, initially available in the Eclipse subfolder plugins/com.prosyst.mbs.mbprofiler_x.x.x. For example, on JDK use the -Xbootclasspath/a: or -Xbootclasspath/p: option.

The following warning will be displayed in case the com.prosyst.mbs.mbprofiler.api.jar archive is missing from the Java classpath of the profiled application:

The absence of the com.prosyst.mbs.mbprofiler.api.jar in the profiled application's class path will lead to the following consequences:

Profiling Agent Arguments

You can pass the following arguments, separated with commas, to the profiler agent by using the relevant JVM-specific profiling startup options:

Option Name and Value

Default Value

Description

transport=socket|ipc

socket

The transport type in use.

server=y|n

n

Whether the profiler agent is the server or not.

suspend=y|n

y

Whether to block for incoming connections or not. Valid only if server=y.

address=[<host>:]<port>[:n]

5115

The host and the port of the profiled application. If mBProfiler is the server, both host and port must be provided. When mBProfiler is a client, only port is required. The "n" argument indicates the number of connection retries that the Profiler Agent will make.

jni=<boolean>

true

Defines if the Java interpreter supports JNI. The default value is "true" (has support). In particular, this argument actually defines if automatic JVM recognition, based on JNI, will be enabled. With JVMs that do not support JNI, this option should be switched off.

Not available if running the mBProfiler version for JVMTI.

jphelper=<boolean>

true

Enables using an internal Java helper profiler class, which is used to perform the toString object command from the visual interface and to control the profiling procedure by means of commands to the agent from within the profiled application itself – see Profiler API. To have this option working you must also have the com.prosyst.mbs.mbprofiler.api.jar file included in the boot classpath (see "Adding the Profiler API to the Java Process" section above).

tostring

true

Activates the support of the toString object command, issued from the visual interface.

loader=<boolean>

true

Enables displaying class loader information.

Not available if running the mBProfiler version for JVMTI.

buff_size=<bytes>

8192

Sets the size in bytes of the socket buffer.

cputime_buff=<bytes>

4096

Sets the size in bytes of the local buffer of each thread for CPU time events.

net=<host>:<port>[:n]

-

Deprecated. Use the server and address arguments instead, that is, server=n and address=<host>:<port>[:n]. Connects to a Profiler Frontend running on the specified remote host and port. The "n" argument specifies the number of connection retries that the Profiler Agent will make.

ipc=<port>

-

Deprecated. Use the transport and address arguments instead, that is, transport=ipc and address=<port>. Connects to the specified named port using Windows IPC.

attach=<port>

-

Deprecated. Use the server, suspend and address arguments instead, that is, server=y, suspend=y and address=<port>[:n]. Blocks the JVM execution waiting for connections on the specified port, that is, until mBProfiler attaches to the process. This is useful if you want to capture all profiling info from the very beginning.

listen=<port>

-

Deprecated. Use the server, suspend and address arguments instead, that is, server=y, suspend=n and address=<port>[:n]. Starts listening for connections on the specified port. The JVM execution is not blocked no matter if mBProfiler is running or not. You can connect and disconnect to the executed application process at any moment.

To get help about the agent's argument, use the help option of the agent. For example: