Warning: This is a development version. The latest stable version is Version 4.0.1.

Performance Counters

In order to monitor the performance of Rely a number of performance counters have been have implemented. These provides a view of the actions taken by both the encoder and the decoder in order to debug / understand any performance issues observed.

There are three ways the performance counters can be read.

  1. The counter can be accessed the individually using the rely::encoder::counter_value() or rely::decoder::counter_value() function and passing the relevant enum counter. This works well if you are only interested in a specific counter value.
  2. The raw memory of all counters may be accessed directly using the rely::decoder::counters_data() and rely::decoder::counters_size() function. This makes it easy to export counters to shared memory or similar. The layout of the raw memory and how to access the different counter values is described below.
  3. Finally all counters can be serialized to JSON. This is done using the rely::decoder::counters_to_json() or rely::encoder::counters_to_json() function. Exporting to JSON should only be used for debugging or similar, for performance critical code option (1) or (2) is preferred.

Note

Some counters are encoder or decoder specific, the validity of a specific counter should therefore always be checked using rely::encoder::counter_is_valid() or rely::decoder::counter_is_valid().

Raw Counter Memory Layout

The counters implementations strives to achieve two goals:

  1. Allow fast export, i.e., it should be possible to copy counters efficiently to shared memory or similar. To allow this we store all counters in a single untyped memory buffer.
  2. Be efficient. Counters and names are grouped in separate sections. Counters are expected to be “hot” therefore grouping them will increase chances of cache hits.

In order to parse the raw memory of the performance counters the format must be specified:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|     Endian    |   Value size  |           Name size           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|            Counters           |             Unused            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                            Name #1                            |
|                       (Name size bytes)                       |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                            Name #2                            |
|                       (Name size bytes)                       |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                            Name #3                            |
|                       (Name size bytes)                       |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
                               ...
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                            Value #1                           |
|                       (Value size bytes)                      |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                            Value #2                           |
|                       (Value size bytes)                      |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                            Value #3                           |
|                       (Value size bytes)                      |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
                               ...
Endian (8 bits)
A zero byte indicates little endian value encoding. Whereas a non-zero value indicates big endian encoding.
Value size (8 bits)
The number of bytes used for each value
Names size (16 bits)
The number of bytes allocated to storing a name. The name will be a zero terminated string of characters. An all zero name indicates an invalid counter.
Counters (16 bits)
The number of counters stored in the memory.
Name (Name size bytes)
The names of each counter.
Value (Value size bytes)
The values of each counter.
Versions
4.0.1
4.0.0
3.0.2
3.0.1
3.0.0
2.0.0
Development
latest