🔧Profiler (Mono)

A Rust (language) native high-speed and lightweight Mono profiler with the ability to profile game assemblies, Carbon, plugins, modules & extensions at high depth.

Introduction

The Mono Profiler is a Carbon built-in feature, offering high performance and convenience, making it ideal for profiling the game, plugins, and more - efficiently.

You may profile the following:

  • Game assemblies (Assembly-CSharp, Facepunch.*, Rust.*, Unity*, System, etc.)

  • Carbon assemblies (Carbon.Common, Carbon.Compat, etc.)

  • Plugin assemblies

  • Module assemblies

  • Extension assemblies

Config

The configuration for the profiler is located atcarbon/config.profiler.json.

config.profiler.json
{
  // Disabling it will shut it off entirely
  "Enabled": true,
  
  // Keeps track of all calls for assemblies and methods
  "TrackCalls": true,
  
  // Disabled by default, allows authorized users to access the Admin module 
  // profiler source viewer and view source code of called methods
  "SourceViewer": true,
  
  // All assemblies and libraries (Rust, Carbon, libs..)
  // Enabling all (*) assemblines, will bypass the categories below
  "Assemblies": [ 
    "Assembly-CSharp",
    "Assembly-CSharp-firstpass"
  ],
  
  // All .cs and .cszip plugins
  "Plugins": [
    "*"
  ],
  
  // All modules from carbon/managed/modules directory
  "Modules": [
    "*"
  ],
  
  // All extensions from carbon/extensions directory
  "Extensions": [
    "Carbon.Ext.MyExtension"
  ],
  
  // All Harmony mods from carbon/harmony directory
  "Harmony": []
}

NOTE

To enable profiling with full selection for one or more categories, use a wildcard/star ( * ).

IMPORTANT

Remove the // comments from the JSON if you're willing to override it locally with it.

Profiler Flags

They're used when starting or stopping the profiler when processing is executed.

NOTE

If the Calls flag is NOT set, only memory allocations will be profiled.

Abort

When the profiler is recording, this flag will terminate recording and discard collected stack and data processed natively.

Memory

Requires the Calls flag to be set. The profiler will keep track of the memory of each call in the stack.

Timings

NOTICE

This flag will significantly affect performance due to having to calculate the time taken on each call.

Requires the Calls flag to be set. The profiler will keep track of the timing & duration information for each call in the stack.

Calls

Whether method calls should be tracked by the current stack.

Commands

As posted under commands, we provide simplified commands for easy and quick management of the profiling process.

Switches in brackets [ ] means that the switch is optional.

c.profile

Starts and stops recording status of the Carbon native Mono-profiling.

Syntax: c.profile [duration]

c.profileabort

Stops and discards any data that has been recorded by the the Carbon native Mono-profiling.

c.profiler.print

If any parsed data available, it'll print basic information of the last profile to console. To get advanced information, write it to file with -f.

Syntax: c.profiler.print [-c|-j|-t] [-f]

The [-c] switch prints the output in CSV format.

The [-j] switch prints the output in JSON format.

The [-t] (default) switch prints the output in table format.

The [-f] switch will write the profile to file in the root directory of the server.

c.profiler.tracks

All tracking lists present in the config which are used by the Mono profiler for tracking.

c.profiler.track

Adds an object to be tracked. Reloading the plugin will start tracking.

Syntax: c.profiler.track (assembly|plugin|module|ext) value

Restarting required for assemblies, modules and extensions.

c.profiler.untrack

Removes a plugin from being tracked. Reloading the plugin will remove it from being tracked.

Syntax: c.profiler.untrack (assembly|plugin|module|ext) value

Restarting required for assemblies, modules and extensions.

Last updated