예제 #1
0
//------------------------------------------------
// Dump a histogram to log.
//
// Note - DO NOT change the log output format in
// this method - tools such as as_log_latency
// assume this format.
//
// TODO - print the scale so as_log_latency can
// label its columns appropriately.
//
void
histogram_dump(histogram *h)
{
	int b;
	uint64_t counts[N_BUCKETS];

	for (b = 0; b < N_BUCKETS; b++) {
		counts[b] = cf_atomic64_get(h->counts[b]);
	}

	int i = N_BUCKETS;
	int j = 0;
	uint64_t total_count = 0;

	for (b = 0; b < N_BUCKETS; b++) {
		if (counts[b] != 0) {
			if (i > b) {
				i = b;
			}

			j = b;
			total_count += counts[b];
		}
	}

	char buf[100];
	int pos = 0;
	int k = 0;

	buf[0] = '\0';

	cf_info(AS_INFO, "histogram dump: %s (%zu total)", h->name, total_count);

	for ( ; i <= j; i++) {
		if (counts[i] == 0) { // print only non-zero columns
			continue;
		}

		int bytes = sprintf(buf + pos, " (%02d: %010zu) ", i, counts[i]);

		if (bytes <= 0) {
			cf_info(AS_INFO, "histogram dump error");
			return;
		}

		pos += bytes;

		if ((k & 3) == 3) { // maximum of 4 printed columns per log line
			 cf_info(AS_INFO, "%s", buf);
			 pos = 0;
			 buf[0] = '\0';
		}

		k++;
	}

	if (pos > 0) {
		cf_info(AS_INFO, "%s", buf);
	}
}
예제 #2
0
//------------------------------------------------
// Save a linear histogram "snapshot".
//
void
linear_histogram_save_info(linear_histogram *h)
{
	pthread_mutex_lock(&h->info_lock);

	// Write num_buckets, the bucket width, and the first bucket's count.
	int i = 0;
	int pos = snprintf(h->info_snapshot, INFO_SNAPSHOT_SIZE, "%d,%ld,%ld",
			h->num_buckets, h->bucket_width, cf_atomic64_get(h->counts[i++]));

	while (pos < INFO_SNAPSHOT_SIZE && i < h->num_buckets) {
		pos += snprintf(h->info_snapshot + pos, INFO_SNAPSHOT_SIZE - pos,
				",%ld", cf_atomic64_get(h->counts[i++]));
	}

	pthread_mutex_unlock(&h->info_lock);
}
예제 #3
0
static void
append_set_props(as_set *p_set, cf_dyn_buf *db)
{
	cf_dyn_buf_append_string(db, "n_objects=");
	cf_dyn_buf_append_uint64(db, cf_atomic64_get(p_set->num_elements));
	cf_dyn_buf_append_char(db, ':');
	cf_dyn_buf_append_string(db, "n-bytes-memory=");
	cf_dyn_buf_append_uint64(db, cf_atomic64_get(p_set->n_bytes_memory));
	cf_dyn_buf_append_char(db, ':');
	cf_dyn_buf_append_string(db, "stop-writes-count=");
	cf_dyn_buf_append_uint64(db, cf_atomic64_get(p_set->stop_writes_count));
	cf_dyn_buf_append_char(db, ':');
	cf_dyn_buf_append_string(db, "set-enable-xdr=");
	if (cf_atomic32_get(p_set->enable_xdr) == AS_SET_ENABLE_XDR_TRUE) {
		cf_dyn_buf_append_string(db, "true");
	}
	else if (cf_atomic32_get(p_set->enable_xdr) == AS_SET_ENABLE_XDR_FALSE) {
		cf_dyn_buf_append_string(db, "false");
	}
	else if (cf_atomic32_get(p_set->enable_xdr) == AS_SET_ENABLE_XDR_DEFAULT) {
		cf_dyn_buf_append_string(db, "use-default");
	}
	else {
		cf_dyn_buf_append_uint32(db, cf_atomic32_get(p_set->enable_xdr));
	}
	cf_dyn_buf_append_char(db, ':');
	cf_dyn_buf_append_string(db, "disable-eviction=");
	if (IS_SET_EVICTION_DISABLED(p_set)) {
		cf_dyn_buf_append_string(db, "true");
	}
	else {
		cf_dyn_buf_append_string(db, "false");
	}
	cf_dyn_buf_append_char(db, ':');
	cf_dyn_buf_append_string(db, "set-delete=");
	if (IS_SET_DELETED(p_set)) {
		cf_dyn_buf_append_string(db, "true");
	}
	else {
		cf_dyn_buf_append_string(db, "false");
	}
	cf_dyn_buf_append_char(db, ';');
}
예제 #4
0
//------------------------------------------------
// Access method for total count.
//
uint64_t
linear_histogram_get_total(linear_histogram *h)
{
	uint64_t total_count = 0;

	for (int i = 0; i < h->num_buckets; i++) {
		total_count += cf_atomic64_get(h->counts[i]);
	}

	return total_count;
}
예제 #5
0
//------------------------------------------------
// Dump a linear histogram to log.
//
// Note - DO NOT change the log output format in
// this method - public documentation assumes this
// format.
//
void
linear_histogram_dump(linear_histogram *h)
{
	int b;
	uint64_t counts[h->num_buckets];

	for (b = 0; b < h->num_buckets; b++) {
		counts[b] = cf_atomic64_get(h->counts[b]);
	}

	int i = h->num_buckets;
	int j = 0;
	uint64_t total_count = 0;

	for (b = 0; b < h->num_buckets; b++) {
		if (counts[b] != 0) {
			if (i > b) {
				i = b;
			}

			j = b;
			total_count += counts[b];
		}
	}

	char buf[100];
	int pos = 0;
	int k = 0;

	buf[0] = '\0';

	cf_debug(AS_NSUP, "linear histogram dump: %s [%u %u]/[%u] (%zu total)",
			h->name, h->start, h->start + (h->num_buckets * h->bucket_width),
			h->bucket_width, total_count);

	for ( ; i <= j; i++) {
		if (counts[i] == 0) { // print only non-zero columns
			continue;
		}

		int bytes = sprintf(buf + pos, " (%02d: %010zu) ", i, counts[i]);

		if (bytes <= 0) {
			cf_debug(AS_NSUP, "linear histogram dump error");
			return;
		}

		pos += bytes;

		if ((k & 3) == 3) { // maximum of 4 printed columns per log line
			 cf_debug(AS_NSUP, "%s", buf);
			 pos = 0;
			 buf[0] = '\0';
		}

		k++;
	}

	if (pos > 0) {
		cf_debug(AS_NSUP, "%s", buf);
	}
}