Memory_profile Plugin

This plugin listens for plugin messages and invokes jemalloc control operations.

Installation

Add the following line to plugin.config:

memory_profile.so

In addition, Traffic Server must be able to read jemalloc configuration information either through the JEMALLOC_CONF environment variable or via the string sym linked to /etc/malloc.conf.

For example, if the string below is in JEMALLOC_CONF or in the sym link string, it enables profiling and indicates that the memory dump prefix is /tmp/jeprof.:

prof:true,prof_prefix:/tmp/jeprof

Details on configuration jemalloc options at <http://jemalloc.net/jemalloc.3.html>. Changes to the configuration in JEMALLOC_CONF or /etc/malloc.conf require a process restart to pick up.

Plugin Messages

The plugin responds to the following messages sent via traffic_ctl.

Message Action ========== =================================================================================== activate Start jemalloc profiling. Useful if prof_active:false was in the configure string.

deactivate Stop jemalloc profiling.

dump If profiling is enabled and active, it will generate a profile dump file.

stats Print jemalloc statistics in traffic.out

The command below sends the stats message to the plugin causing the current statistics to be written to traffic.out:

traffic_ctl plugin msg memory_profile stats

Example Usage

If your run time configuration string is:

prof:true,prof_prefix:/tmp/jeprof:prof_active:false

Traffic Server has started without profile sampling started. Perhaps you didn't want to profile the start up phase of Traffic Server. To start you need to send the activate message to the plugin:

traffic_ctl plugin msg memory_profile activate

If your run time configuration string does not indicate that the profiling is not started (e.g. the prof_active field is missing or set to true), you do not need to send the activate message.

After waiting sometime for Traffic Server to gather some memory allocation data, you can send the dump message:

traffic_ctl plugin msg memory_profile dump

This will cause a file containing information about the current state of the Traffic Server memory allocation to be dumped in a file prefixed by the value of prof_prefix. In this example, it would be something like /tmp/jeprof.1234.0.m0.heap, where 1234 is the process id and 0 is a running counter indicating how many dumps have been performed on this process. Each dump is independent of the others and records the current stat of allocations since the profiling was activated. The dump file can be processed by jeprof to get text output or graphs. Details of how to use jeprof are in the man pages or <https://manpages.debian.org/unstable/libjemalloc-dev/jeprof.1.en.html>.

You may want to send the dump message periodically to analyze how the Traffic Server memory allocation changes over time. This periodic dump can also be achieved by setting the lg_prof_interval option in the run time configuration string.

If the profiling is taking a significant amount of processing time and affecting Traffic Server performance, send the deactivate message to turn off profiling.:

traffic_ctl plugin msg memory_profile deactivate

Send the stats message to cause detailed jemalloc stats to be printed in traffic.out. These stats represent activity since the start of the Traffic Server process.:

traffic_ctl plugin msg memory_profile stats

Limitations

Currently the plugin only functions for systems compiled against jemalloc. Perhaps in the future, it can be augmented to interact with other memory allocation systems.