You can profile running StreamBase applications to gather statistics about operators, threads, and streams in that application. The gathered statistics include:
-
The percentage of CPU time used by each operator.
-
The cumulative time spent in each operator, in milliseconds.
-
The number of tuples processed by each operator.
You can profile interactively to see statistics while an application runs, or you can gather statistics into a file, then analyze and format the results for review.
The profiling system shows meaningful statistics only for operators that have run for a while. It is common to have StreamBase applications with operators that use no measurable amount of time when the application has not run very long or has not run with much data.
When a StreamBase application starts, the JVM associated with StreamBase Server interprets the bytecodes at the start of execution and then compiles them into native CPU instructions and optimizes as the application is run. So when profiling, the start of the run does not reflect the timing of the application once it has been optimized. Therefore, the longer the application runs, the more accurate the profile.
Both interactive profiling and after-the-fact statistics analysis are accomplished with the sbprofile command. This command is run at a UNIX shell prompt or, for Windows, at a StreamBase Command Prompt.
You can profile interactively in two ways:
-
Use the Profile View in the StreamBase Monitor
-
Run sbprofile interactively
The Profile View of the StreamBase Monitor screen shows statistics accumulated since the connected StreamBase Server instance started. The statistics collected are:
-
The percentage of time spent in each operator.
-
The exponentially weighted moving average of wall-clock time per input tuple in microseconds.
-
For certain operators, the accumulated size.
See Using StreamBase Monitor for instructions on running the sbmonitor command and using its Profile View.
Run sbprofile interactively by specifying its –u option with its –i option and an interval in seconds, like this example:
sbprofile -u sb://localhost:10000 -i 5
This example requests a profiling report to be printed to the shell window every five seconds. The command collects statistics until it is stopped with Ctrl-C or the server shuts down. By default, the report is in CSV format. The following example shows interactive profiling of the Best Bids and Asks sample shipped with StreamBase:
default.PreserveBidInfo, 1.58, 2,280, N/A default.PreserveAskInfo, 1.36, 1,959, N/A default.IsNewBestAsk, 0.01, 10, N/A default.Update_Bids_and_Asks, 0.23, 333, 3,307 default.IsNewBestBid, 0.01, 10, N/A
Reports generated with the –i option cannot be
redirected with the –o option or with the shell
redirection operator >.
You can gather statistics from a running StreamBase application, and save those statistics to a file, using a command like the following:
sbc -u URI dequeue system.stat > statfile.txt
Substitute the URI of your running StreamBase application using the standard StreamBase URI format, or one of its shortcuts, as described in the sburi reference page.
The statistics-gathering sbc command runs until either the StreamBase Server instance shuts down, or you type Ctrl-C to stop the sbc command.
Generate a statistic report from your saved statistics file with a command like the following:
sbprofile -s statfile.txt
By default, or if you specify –F csv, the report is in
CSV format as shown in the interactive example above. You can also specify
–F html to write the report in a simple HTML table for
viewing in a browser. For example:
sbprofile -s statfile.txt -F html > statreport.html firefox statreport.html
The resulting table is similar to the following example:
| Operator Name | Percent Time | Operator Time (ms) | Operator Size |
|---|---|---|---|
| default.PreserveBidInfo | 0.41 | 2,316 | N/A |
| default.PreserveAskInfo | 0.35 | 2.015 | N/A |
| default.IsNewBestAsk | 0 | 26 | N/A |
| default.Update_Bids_and_Asks | 0.09 | 519 | 3,307 |
| default.IsNewBestBid | 0 | 21 | N/A |
