SingleStore Managed Service

Understanding memory_bs

When reporting memory usage by activities, we report a metric that represents the memory requirements of that activity. To understand, we need to look at a chart of memory used by a connection over time.

In this chart of memory usage over a time, the connection runs many small short lived queries. While each query is running, it uses a small amount of memory:

16083b579d8442.png

We want to report the memory used by these queries in an interval, for example during the grey interval:

16083b579df0a8.png

The following figure shows a different connection, with a single long running query that consumes a moderate amount of memory. During the grey interval, it reserves substantially more memory than the first connection of small short queries:

16083b579e6b92.png

Here is a last connection, with a single expensive but short lived query that uses a large amount of memory. During the grey interval, it has a higher maximum amount of memory used; however, it is less costly to run:

16083b579eea0f.png

The last query is substantially less expensive than the previous query because it released its memory quickly. If the height of the chart is the maximum amount of memory available, the amount of the grey rectangle covered up by our blue queries represents how expensive the queries are. This area is measured in byte seconds and is calculated by multiplying the maximum memory used by a query by the elapsed time (i.e. the amount of time it held that memory and prevented other queries from using it).

Sample Query for memory_bs

To find the average memory used by a query, execute a query similar to the following:

memsql> use information_schema;
memsql> select 1000*memory_bs/elapsed_time_ms as avg_memory_used_b,
activity_name from mv_activities;
+-------------------+------------------------------------------------------------------+
| avg_memory_used_b | activity_name                                                    |
+-------------------+------------------------------------------------------------------+
|            0.0000 | registrationRunner                                               |
|            0.0000 | SlaveHandler_StreamFiles                                         |
|            0.0000 | ShardingPartition::WorkerThread                                  |
|        26192.8233 | ReadAndExecuteLoop                                               |
|            0.0000 | LogFlusherThreadFunc                                             |
|            0.0000 | SecondaryReplayThread::Run                                           |
|            0.0000 | LogFlusher                                                       |
|      1143400.0000 | Select_MV_ACTIVITIES_EXTENDED_CUMULATIVE__et_al_23409c29b9e1dd98 |                                        |
+-------------------+------------------------------------------------------------------+