Exemplo n.º 1
0
void ia_kvpool_fill(struct iakvpool *pool, size_t nbandles, size_t nelem)
{
	size_t i, j, bytes = nbandles * nelem * (pool->vsize + pool->ksize);
	char* dst = realloc(pool->flat, bytes);
	if (! dst) {
		ia_log("error: out of memory");
		ia_fatal(__func__);
	}

	pool->flat = dst;
	for (i = 0; i < nbandles; ++i) {
		uint64_t point = pool->space + pool->serial;
		pool->serial = (pool->serial + 1) % pool->period;

		for (j = 0; j < nelem; ++j) {
			dst = kv_rnd(&point, dst, !ioarena.conf.binary, pool->ksize);
			if (pool->vsize)
				dst = kv_rnd(&point, dst, !ioarena.conf.binary, pool->vsize);
		}
	}

	assert(dst == pool->flat + bytes);
	pool->pos = 0;
	pool->power = bytes;
}
Exemplo n.º 2
0
Arquivo: ia.c Projeto: nmter/ioarena
static void ia_sync_fihish(ia *a)
{
	int rc = pthread_barrier_wait(&a->barrier_fihish);
	if (rc != 0 && rc != PTHREAD_BARRIER_SERIAL_THREAD) {
		ia_log("error: pthread_barrier_wait %s (%d)", strerror(rc), rc);
		ia_fatal(__func__);
	}
}
Exemplo n.º 3
0
void ia_histogram_merge(iahistogram *src)
{
	if (src->acc.n - src->last.n) {
		ia_timestamp_t now = ia_timestamp_ns();
		if (pthread_mutex_lock(&global.mutex))
			ia_fatal(__FUNCTION__);

		ia_histogram_merge_locked(src, now);
		pthread_mutex_unlock(&global.mutex);
	}
}
Exemplo n.º 4
0
Arquivo: ia.c Projeto: nmter/ioarena
static void ia_sync_start(ia *a)
{
#ifdef _POSIX_PRIORITY_SCHEDULING
	sched_yield();
#elif defined(__APPLE__) || defined(__MACH__)
	pthread_yield_np();
#else
	pthread_yield();
#endif
	int rc = pthread_barrier_wait(&a->barrier_start);
	if (rc != 0 && rc != PTHREAD_BARRIER_SERIAL_THREAD) {
		ia_log("error: pthread_barrier_wait %s (%d)", strerror(rc), rc);
		ia_fatal(__func__);
	}
}
Exemplo n.º 5
0
void ia_histogram_destroy(iahistogram *h)
{
	if (h->enabled == 42) {
		h->enabled = 0;
		if (h->merge_evo == global.merge_evo + 1) {
			if (pthread_mutex_lock(&global.mutex))
				ia_fatal(__FUNCTION__);
			if (h->merge_evo == global.merge_evo + 1)
				global.doers_merged -= 1;
			__sync_fetch_and_add(&global.doers_active, -1);
			pthread_mutex_unlock(&global.mutex);
		} else
			__sync_fetch_and_add(&global.doers_active, -1);
	}
}
Exemplo n.º 6
0
int ia_histogram_checkpoint(ia_timestamp_t now)
{
	if (now) {
		if (now - global.checkpoint_ns < INTERVAL_STAT)
			return -1;
		if (global.doers_active > ++global.doers_merged)
			return 0;
	}

	if (global.doers_active != global.doers_merged)
		ia_fatal(__FUNCTION__);

	if (! now)
		now = ia_timestamp_ns();

	iahistogram *h;
	char line[1024], *s;

	if (global.checkpoint_ns == global.starting_point) {
		s = line;

		s += snprintf(s, line + sizeof(line) - s, "     time");
		if (global.csv_timeline)
			fprintf(global.csv_timeline, "\ttime" );

		for (h = global.per_bench; h < global.per_bench + IA_MAX; ++h) {
			if (! h->enabled)
				continue;

			const char *name = ia_benchmarkof(h->bench);
			s += snprintf(s, line + sizeof(line) - s,
				" | bench      rps      min       avg       rms       max       vol           #N");
			if (global.csv_timeline)
				fprintf(global.csv_timeline, ",\t%s_rps,\t%s_min,\t%s_avg,\t%s_rms,\t%s_max", name, name, name, name, name);
		}

		if (global.csv_timeline)
			fprintf(global.csv_timeline, "\n");
		ia_log("%s", line);
	}

	s = line;
	const double timepoint = (now - global.starting_point) / (double) S;
	s += snprintf(s, line + sizeof(line) - s, "%9.3f", timepoint);
	if (global.csv_timeline)
		fprintf(global.csv_timeline, "%e", timepoint);

	const ia_timestamp_t wall_ns = now - global.checkpoint_ns;
	const double wall = wall_ns / (double) S;
	global.checkpoint_ns = now;

	for (h = global.per_bench; h < global.per_bench + IA_MAX; ++h) {
		if (! h->enabled)
			continue;

		const char *name = ia_benchmarkof(h->bench);
		const uint64_t n = h->acc.n - h->last.n;
		const uint64_t vol = h->acc.volume_sum - h->last.volume_sum;

		s += snprintf(s, line + sizeof(line) - s, " | %5s", name );
		if (n) {
			const ia_timestamp_t rms = sqrt((h->acc.latency_sum_square - h->last.latency_sum_square) / n);
			const ia_timestamp_t avg = (h->acc.latency_sum_ns - h->last.latency_sum_ns) / n;
			const double rps = n / wall;
			const double bps = vol / wall;

			if (global.csv_timeline) {
				fprintf(global.csv_timeline, ",\t%e,\t%e,\t%e,\t%e,\t%e",
					rps, h->min / (double) S, avg / (double) S, rms / (double) S, h->max / (double) S);
			}

			s += snprintf(s, line + sizeof(line) - s, ":");
			s += snpf_val(s, line + sizeof(line) - s, rps, "");
			s += snpf_lat(s, line + sizeof(line) - s, h->min);
			s += snpf_lat(s, line + sizeof(line) - s, avg);
			s += snpf_lat(s, line + sizeof(line) - s, rms);
			s += snpf_lat(s, line + sizeof(line) - s, h->max);

			s += snpf_val(s, line + sizeof(line) - s, bps, "bps");
			s += snpf_val(s, line + sizeof(line) - s, h->acc.n, "");
		}
		else {
			s += snprintf(s, line + sizeof(line) - s,
				"        -        -         -         -         -         -           - ");
			if (global.csv_timeline) {
				fprintf(global.csv_timeline, ",\t\t,\t\t,\t\t,\t\t");
			}
		}

		if (h->whole_min > h->min)
			h->whole_min = h->min;
		h->min = ~0ull;

		if (h->whole_max < h->max)
			h->whole_max = h->max;
		h->max = 0;

		h->last = h->acc;
	}

	if (global.csv_timeline) {
		fprintf(global.csv_timeline, "\n");
		fflush(global.csv_timeline);
	}
	ia_log("%s", line);

	assert(global.doers_active == global.doers_merged);
	global.doers_merged = 0;
	global.merge_evo += 1;
	return 1;
}