Enlarge statistics variables from 32 to 64 bit
Apparently at least the epoll cycles can wrap. Also use integer types of explicit size.
This commit is contained in:
@ -11,6 +11,7 @@
|
|||||||
* Public License.
|
* Public License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <inttypes.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@ -164,11 +165,11 @@ static struct
|
|||||||
ts_stats_t *n_pollev; /*< Number of polls returning events */
|
ts_stats_t *n_pollev; /*< Number of polls returning events */
|
||||||
ts_stats_t *n_nbpollev; /*< Number of polls returning events */
|
ts_stats_t *n_nbpollev; /*< Number of polls returning events */
|
||||||
ts_stats_t *n_nothreads; /*< Number of times no threads are polling */
|
ts_stats_t *n_nothreads; /*< Number of times no threads are polling */
|
||||||
int n_fds[MAXNFDS]; /*< Number of wakeups with particular n_fds value */
|
int32_t n_fds[MAXNFDS]; /*< Number of wakeups with particular n_fds value */
|
||||||
int evq_length; /*< Event queue length */
|
int32_t evq_length; /*< Event queue length */
|
||||||
int evq_pending; /*< Number of pending descriptors in event queue */
|
int32_t evq_pending; /*< Number of pending descriptors in event queue */
|
||||||
int evq_max; /*< Maximum event queue length */
|
int32_t evq_max; /*< Maximum event queue length */
|
||||||
int wake_evqpending; /*< Woken from epoll_wait with pending events in queue */
|
int32_t wake_evqpending; /*< Woken from epoll_wait with pending events in queue */
|
||||||
ts_stats_t *blockingpolls; /*< Number of epoll_waits with a timeout specified */
|
ts_stats_t *blockingpolls; /*< Number of epoll_waits with a timeout specified */
|
||||||
} pollStats;
|
} pollStats;
|
||||||
|
|
||||||
@ -178,10 +179,10 @@ static struct
|
|||||||
*/
|
*/
|
||||||
static struct
|
static struct
|
||||||
{
|
{
|
||||||
unsigned int qtimes[N_QUEUE_TIMES + 1];
|
uint32_t qtimes[N_QUEUE_TIMES + 1];
|
||||||
unsigned int exectimes[N_QUEUE_TIMES + 1];
|
uint32_t exectimes[N_QUEUE_TIMES + 1];
|
||||||
unsigned long maxqtime;
|
uint64_t maxqtime;
|
||||||
unsigned long maxexectime;
|
uint64_t maxexectime;
|
||||||
} queueStats;
|
} queueStats;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1258,42 +1259,42 @@ dprintPollStats(DCB *dcb)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
dcb_printf(dcb, "\nPoll Statistics.\n\n");
|
dcb_printf(dcb, "\nPoll Statistics.\n\n");
|
||||||
dcb_printf(dcb, "No. of epoll cycles: %d\n",
|
dcb_printf(dcb, "No. of epoll cycles: %" PRId64 "\n",
|
||||||
ts_stats_sum(pollStats.n_polls));
|
ts_stats_sum(pollStats.n_polls));
|
||||||
dcb_printf(dcb, "No. of epoll cycles with wait: %d\n",
|
dcb_printf(dcb, "No. of epoll cycles with wait: %" PRId64 "\n",
|
||||||
ts_stats_sum(pollStats.blockingpolls));
|
ts_stats_sum(pollStats.blockingpolls));
|
||||||
dcb_printf(dcb, "No. of epoll calls returning events: %d\n",
|
dcb_printf(dcb, "No. of epoll calls returning events: %" PRId64 "\n",
|
||||||
ts_stats_sum(pollStats.n_pollev));
|
ts_stats_sum(pollStats.n_pollev));
|
||||||
dcb_printf(dcb, "No. of non-blocking calls returning events: %d\n",
|
dcb_printf(dcb, "No. of non-blocking calls returning events: %" PRId64 "\n",
|
||||||
ts_stats_sum(pollStats.n_nbpollev));
|
ts_stats_sum(pollStats.n_nbpollev));
|
||||||
dcb_printf(dcb, "No. of read events: %d\n",
|
dcb_printf(dcb, "No. of read events: %" PRId64 "\n",
|
||||||
ts_stats_sum(pollStats.n_read));
|
ts_stats_sum(pollStats.n_read));
|
||||||
dcb_printf(dcb, "No. of write events: %d\n",
|
dcb_printf(dcb, "No. of write events: %" PRId64 "\n",
|
||||||
ts_stats_sum(pollStats.n_write));
|
ts_stats_sum(pollStats.n_write));
|
||||||
dcb_printf(dcb, "No. of error events: %d\n",
|
dcb_printf(dcb, "No. of error events: %" PRId64 "\n",
|
||||||
ts_stats_sum(pollStats.n_error));
|
ts_stats_sum(pollStats.n_error));
|
||||||
dcb_printf(dcb, "No. of hangup events: %d\n",
|
dcb_printf(dcb, "No. of hangup events: %" PRId64 "\n",
|
||||||
ts_stats_sum(pollStats.n_hup));
|
ts_stats_sum(pollStats.n_hup));
|
||||||
dcb_printf(dcb, "No. of accept events: %d\n",
|
dcb_printf(dcb, "No. of accept events: %" PRId64 "\n",
|
||||||
ts_stats_sum(pollStats.n_accept));
|
ts_stats_sum(pollStats.n_accept));
|
||||||
dcb_printf(dcb, "No. of times no threads polling: %d\n",
|
dcb_printf(dcb, "No. of times no threads polling: %" PRId64 "\n",
|
||||||
ts_stats_sum(pollStats.n_nothreads));
|
ts_stats_sum(pollStats.n_nothreads));
|
||||||
dcb_printf(dcb, "Current event queue length: %d\n",
|
dcb_printf(dcb, "Current event queue length: %" PRId32 "\n",
|
||||||
pollStats.evq_length);
|
pollStats.evq_length);
|
||||||
dcb_printf(dcb, "Maximum event queue length: %d\n",
|
dcb_printf(dcb, "Maximum event queue length: %" PRId32 "\n",
|
||||||
pollStats.evq_max);
|
pollStats.evq_max);
|
||||||
dcb_printf(dcb, "No. of DCBs with pending events: %d\n",
|
dcb_printf(dcb, "No. of DCBs with pending events: %" PRId32 "\n",
|
||||||
pollStats.evq_pending);
|
pollStats.evq_pending);
|
||||||
dcb_printf(dcb, "No. of wakeups with pending queue: %d\n",
|
dcb_printf(dcb, "No. of wakeups with pending queue: %" PRId32 "\n",
|
||||||
pollStats.wake_evqpending);
|
pollStats.wake_evqpending);
|
||||||
|
|
||||||
dcb_printf(dcb, "No of poll completions with descriptors\n");
|
dcb_printf(dcb, "No of poll completions with descriptors\n");
|
||||||
dcb_printf(dcb, "\tNo. of descriptors\tNo. of poll completions.\n");
|
dcb_printf(dcb, "\tNo. of descriptors\tNo. of poll completions.\n");
|
||||||
for (i = 0; i < MAXNFDS - 1; i++)
|
for (i = 0; i < MAXNFDS - 1; i++)
|
||||||
{
|
{
|
||||||
dcb_printf(dcb, "\t%2d\t\t\t%d\n", i + 1, pollStats.n_fds[i]);
|
dcb_printf(dcb, "\t%2d\t\t\t%" PRId32 "\n", i + 1, pollStats.n_fds[i]);
|
||||||
}
|
}
|
||||||
dcb_printf(dcb, "\t>= %d\t\t\t%d\n", MAXNFDS,
|
dcb_printf(dcb, "\t>= %d\t\t\t%" PRId32 "\n", MAXNFDS,
|
||||||
pollStats.n_fds[MAXNFDS - 1]);
|
pollStats.n_fds[MAXNFDS - 1]);
|
||||||
|
|
||||||
#if SPINLOCK_PROFILE
|
#if SPINLOCK_PROFILE
|
||||||
|
@ -58,7 +58,7 @@ void ts_stats_end()
|
|||||||
ts_stats_t ts_stats_alloc()
|
ts_stats_t ts_stats_alloc()
|
||||||
{
|
{
|
||||||
ss_dassert(stats_initialized);
|
ss_dassert(stats_initialized);
|
||||||
return MXS_CALLOC(thread_count, sizeof(int));
|
return MXS_CALLOC(thread_count, sizeof(int64_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -80,13 +80,13 @@ void ts_stats_free(ts_stats_t stats)
|
|||||||
* @param stats Statistics to read
|
* @param stats Statistics to read
|
||||||
* @return Value of statistics
|
* @return Value of statistics
|
||||||
*/
|
*/
|
||||||
int ts_stats_sum(ts_stats_t stats)
|
int64_t ts_stats_sum(ts_stats_t stats)
|
||||||
{
|
{
|
||||||
ss_dassert(stats_initialized);
|
ss_dassert(stats_initialized);
|
||||||
int sum = 0;
|
int64_t sum = 0;
|
||||||
for (int i = 0; i < thread_count; i++)
|
for (int i = 0; i < thread_count; i++)
|
||||||
{
|
{
|
||||||
sum += ((int*)stats)[i];
|
sum += ((int64_t*)stats)[i];
|
||||||
}
|
}
|
||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,8 @@
|
|||||||
* @endverbatim
|
* @endverbatim
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
typedef void* ts_stats_t;
|
typedef void* ts_stats_t;
|
||||||
|
|
||||||
/** stats_init should be called only once */
|
/** stats_init should be called only once */
|
||||||
@ -35,7 +37,7 @@ void ts_stats_end();
|
|||||||
|
|
||||||
ts_stats_t ts_stats_alloc();
|
ts_stats_t ts_stats_alloc();
|
||||||
void ts_stats_free(ts_stats_t stats);
|
void ts_stats_free(ts_stats_t stats);
|
||||||
int ts_stats_sum(ts_stats_t stats);
|
int64_t ts_stats_sum(ts_stats_t stats);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Increment thread statistics by one
|
* @brief Increment thread statistics by one
|
||||||
@ -46,7 +48,7 @@ int ts_stats_sum(ts_stats_t stats);
|
|||||||
static void inline
|
static void inline
|
||||||
ts_stats_increment(ts_stats_t stats, int thread_id)
|
ts_stats_increment(ts_stats_t stats, int thread_id)
|
||||||
{
|
{
|
||||||
((int*)stats)[thread_id]++;
|
((int64_t*)stats)[thread_id]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -63,7 +65,7 @@ ts_stats_increment(ts_stats_t stats, int thread_id)
|
|||||||
static void inline
|
static void inline
|
||||||
ts_stats_set(ts_stats_t stats, int value, int thread_id)
|
ts_stats_set(ts_stats_t stats, int value, int thread_id)
|
||||||
{
|
{
|
||||||
((int*)stats)[thread_id] = value;
|
((int64_t*)stats)[thread_id] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user