C3 AI Documentation Home

Analyze Code Using the Action Profiler

The action profiler helps an advanced developer diagnose code performance issues. An action is a task executed by a piece of code. You can drill into individual code execution actions and sub-actions to visualize statistics about how each action runs over time. You can expand tasks and sub-tasks as many times as needed. There is no limit to the number of levels you can drill into using the action profiler.

With the action profiler, you can:

  • Search for actions
  • Profile past root actions
  • Profile actions in a multi-node environment
  • Profile actions within your application

Visualize code actions in a:

  • Tree view
  • Flame graph

You can see the following data for actions and child actions:

  • T. Time — Total time it took for the action to complete
  • S. Time — Time spent in the action itself
  • T. CPU — CPU time
  • S. CPU — CPU time spent in the action itself
  • T. IO — Total IO time (SQL / Key Value Pairs / other input and output)
  • S. IO — Input/output time spent in the action itself
  • T. KV — Total key value time
  • S. KV — Key value store time spent 
  • T. SQL — Total SQL time
  • S. SQL — SQL time spent in the action itself

Aggregate the data by the following mathematical functions for each kind of action data:

  • Sum
  • Mean
  • Median
  • Maximum
  • Third quartile
  • 90th percentile

For example, you can choose to see the sum of the total time the action took to complete (T. Time), the mean of the total time the action took to complete, the mean of the total time it took the action to complete, etc.

You can change the format of the action data to:

  • Time
  • Time with ms
  • Seconds
  • Seconds with ms
  • Milliseconds

You can filter by type of action or for a specific timeframe.

Analyze code using the action profiler

Prerequisites:

  • Create an app with one or more actions
  • AppAdmin or higher permissions

To analyze code using the action profiler:

  1. In C3 AI Studio, navigate to Apps.
  2. Select an application, then navigate to Workload Management > Action Profiler.
  3. Search for the action you want to analyze.
  4. Select the action to open the Action profiler.

You can now see the actions in a tree view. You can expand each level in the tree view to see data for individual actions and sub-actions.

Find actions

You can find currently running and past actions in the action profiler.

You can search completed actions by using C3 AI Types and actions.

You can change the format of the time measurement by selecting an option under Format. And you can set the aggregation type under Aggregation.

You can filter actions by:

  • Action type. Under Filter by, your options are:
    • Interesting actions
    • Root actions
    • All actions
  • Time the action ran under Timestamp

You can group actions in the list by:

  • Both type and action
  • Action
  • Individual actions

Change the format of the action data

You can change the format of the action data to:

  • Time
  • Time with ms
  • Seconds
  • Seconds with ms
  • Milliseconds

To change the format of the action data:

  1. In C3 AI Studio, navigate to Apps.
  2. Select an application, then navigate to Workload Management > Action Profiler.
  3. In the left nav, select the dropdown under Format and choose another format.

Actions display in the format you selected.

Visualizations

View actions in a tree view

To analyze code using the action profiler:

  1. In C3 AI Studio, navigate to Apps.
  2. Select an application, then navigate to Workload Management > Action Profiler.
  3. Search for the action you want to analyze.
  4. Select the action to open the Action profiler.

You can now see the actions in a tree view. You can expand each level in the tree view to see data for individual actions and sub-actions.

View actions in a flame graph

To analyze code using the action profiler:

  1. In C3 AI Studio, navigate to Apps.
  2. Select an application, then navigate to Workload Management > Action Profiler.
  3. Search for the action you want to analyze.
  4. Select the app to open the Action profiler.
  5. Select Flame Graph to see the flame graph.

Profile past root actions

The action profiler allows you to see data about past actions. See past actions by:

  1. In C3 AI Studio, navigate to Apps.
  2. Select an application, then navigate to Workload Management > Action Profiler.
  3. In Filter by, select Root actions.

Profile actions in a multi-node environment

If you application is running in a multi-node environment, all the actions listed are collected from all the nodes within your app.

Profile actions within your application

When you open action profiler in Studio, it only shows actions that belong to your application.

Examples

The following examples show how the action profiler displays a tree view and a flame graph for a set of sample code.

The following code shows an action with child actions you can turn on and off. When TestActionProfilerMain.mainAction() is set to false, this code prints “I love C3” in one action. When TestActionProfilerMain.mainAction() is set to true, this code prints “I love C3” in 3 child actions.

Type
type TestActionProfilerMain {
  mainAction: function(childAction: !boolean): string py-server
}
Python
def mainAction(cls, childAction):
    import time
    import random
    if childAction:
        a = c3.TestActionProfilerChild.childAction('I ')
        b = c3.TestActionProfilerChild.childAction('love ')
        c = c3.TestActionProfilerChild.childAction('C3 ')
        return a+b+c
    else:
        time.sleep(random.random())
        return "I love C3"
Type
type TestActionProfilerChild {
  childAction: function(input: !string): string py-server
}
Python
def childAction(cls, input):
    import time
    time.sleep(1)
    return input 

Example 1: Code with no child actions

When TestActionProfilerMain.mainAction() is set to false, the action profiler shows the actions and child actions in the flame graph. Expand all types for a drill down view of the action profiler.

Example 2: Code with child actions

When TestActionProfilerMain.mainAction() is set to true, the action profiler shows the actions in the code and the child actions in the flame graph.

You can drill down on the child actions to see what is happening at each stage of the code.

Was this page helpful?