MXS-1674 Change load granularity to 1 second
With a granularity of 1 second, the load will from a human perspective reflect the current situation. That also means that the maxadmin output shows "natural" steps; 1s, 1m and 1h.
This commit is contained in:
@ -79,14 +79,14 @@ class WorkerLoad
|
|||||||
public:
|
public:
|
||||||
enum counter_t
|
enum counter_t
|
||||||
{
|
{
|
||||||
TEN_SECONDS = 10 * 1000,
|
ONE_SECOND = 1000,
|
||||||
ONE_MINUTE = 6 * TEN_SECONDS,
|
ONE_MINUTE = 60 * ONE_SECOND,
|
||||||
ONE_HOUR = 60 * ONE_MINUTE,
|
ONE_HOUR = 60 * ONE_MINUTE,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
GRANULARITY = TEN_SECONDS
|
GRANULARITY = ONE_SECOND
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -143,8 +143,8 @@ public:
|
|||||||
{
|
{
|
||||||
switch (counter)
|
switch (counter)
|
||||||
{
|
{
|
||||||
case TEN_SECONDS:
|
case ONE_SECOND:
|
||||||
return m_load_10_seconds.value();
|
return m_load_1_second.value();
|
||||||
|
|
||||||
case ONE_MINUTE:
|
case ONE_MINUTE:
|
||||||
return m_load_1_minute.value();
|
return m_load_1_minute.value();
|
||||||
@ -159,7 +159,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When was the last 10 second period started.
|
* When was the last 1 second period started.
|
||||||
*
|
*
|
||||||
* @return The start time.
|
* @return The start time.
|
||||||
*/
|
*/
|
||||||
@ -414,12 +414,12 @@ private:
|
|||||||
uint32_t m_nValues; /*< How many values the buffer contains. */
|
uint32_t m_nValues; /*< How many values the buffer contains. */
|
||||||
};
|
};
|
||||||
|
|
||||||
uint64_t m_start_time; /*< When was a new 10-second period started. */
|
uint64_t m_start_time; /*< When was the current 1-second period started. */
|
||||||
uint64_t m_wait_start; /*< The time when the worker entered epoll_wait(). */
|
uint64_t m_wait_start; /*< The time when the worker entered epoll_wait(). */
|
||||||
uint64_t m_wait_time; /*< How much time the worker has spent in epoll_wait(). */
|
uint64_t m_wait_time; /*< How much time the worker has spent in epoll_wait(). */
|
||||||
AverageN<60> m_load_1_hour; /*< The average load during the last hour. */
|
AverageN<60> m_load_1_hour; /*< The average load during the last hour. */
|
||||||
AverageN<6> m_load_1_minute; /*< The average load during the last minute. */
|
AverageN<60> m_load_1_minute; /*< The average load during the last minute. */
|
||||||
Average1 m_load_10_seconds; /*< The load during the last 10-second period. */
|
Average1 m_load_1_second; /*< The load during the last 1-second period. */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -240,8 +240,8 @@ dShowThreads(DCB *dcb)
|
|||||||
{
|
{
|
||||||
dcb_printf(dcb, "Polling Threads.\n\n");
|
dcb_printf(dcb, "Polling Threads.\n\n");
|
||||||
|
|
||||||
dcb_printf(dcb, " ID | State | #descriptors (curr) | #descriptors (tot) | Load (10s) | Load (1m) | Load (1h) |\n");
|
dcb_printf(dcb, " ID | State | #descriptors (curr) | #descriptors (tot) | Load (1s) | Load (1m) | Load (1h) |\n");
|
||||||
dcb_printf(dcb, "----+------------+---------------------+---------------------+------------+-----------+-----------+\n");
|
dcb_printf(dcb, "----+------------+---------------------+---------------------+-----------+-----------+-----------+\n");
|
||||||
for (int i = 0; i < n_threads; i++)
|
for (int i = 0; i < n_threads; i++)
|
||||||
{
|
{
|
||||||
Worker* worker = Worker::get(i);
|
Worker* worker = Worker::get(i);
|
||||||
@ -276,9 +276,9 @@ dShowThreads(DCB *dcb)
|
|||||||
|
|
||||||
worker->get_descriptor_counts(&nCurrent, &nTotal);
|
worker->get_descriptor_counts(&nCurrent, &nTotal);
|
||||||
|
|
||||||
dcb_printf(dcb, " %2d | %10s | %19" PRIu32 " | %19" PRIu64 " | %10d | %9d | %9d |\n",
|
dcb_printf(dcb, " %2d | %10s | %19" PRIu32 " | %19" PRIu64 " | %9d | %9d | %9d |\n",
|
||||||
i, state, nCurrent, nTotal,
|
i, state, nCurrent, nTotal,
|
||||||
worker->load(Worker::Load::TEN_SECONDS),
|
worker->load(Worker::Load::ONE_SECOND),
|
||||||
worker->load(Worker::Load::ONE_MINUTE),
|
worker->load(Worker::Load::ONE_MINUTE),
|
||||||
worker->load(Worker::Load::ONE_HOUR));
|
worker->load(Worker::Load::ONE_HOUR));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -160,7 +160,7 @@ WorkerLoad::WorkerLoad()
|
|||||||
, m_wait_start(0)
|
, m_wait_start(0)
|
||||||
, m_wait_time(0)
|
, m_wait_time(0)
|
||||||
, m_load_1_minute(&m_load_1_hour)
|
, m_load_1_minute(&m_load_1_hour)
|
||||||
, m_load_10_seconds(&m_load_1_minute)
|
, m_load_1_second(&m_load_1_minute)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,14 +170,14 @@ void WorkerLoad::about_to_work(uint64_t now)
|
|||||||
|
|
||||||
m_wait_time += (now - m_wait_start);
|
m_wait_time += (now - m_wait_start);
|
||||||
|
|
||||||
if (duration > TEN_SECONDS)
|
if (duration > ONE_SECOND)
|
||||||
{
|
{
|
||||||
int load_percentage = 100 * ((duration - m_wait_time) / (double)duration);
|
int load_percentage = 100 * ((duration - m_wait_time) / (double)duration);
|
||||||
|
|
||||||
m_start_time = now;
|
m_start_time = now;
|
||||||
m_wait_time = 0;
|
m_wait_time = 0;
|
||||||
|
|
||||||
m_load_10_seconds.add_value(load_percentage);
|
m_load_1_second.add_value(load_percentage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user