Skip to content
Permalink
Browse files

sysbench memory tweaks

* Use a larger sample size for sysbench 1.0+ and 64-bit
* Store pointer size with bench results
* Re-enable single thread memory benchmark

Use a larger sample size where available. The small size was
chosen because the 32-bit ARM sysbench 0.4x in raspbian
can't do more than about ~4G, but the problem is that much more
powerful machines burn through that very quickly. The result is
in MiB/s so it should still be comparable, but the results should
be more stable.

Noticed with Ryzen that multi-thread varies significantly based on
what threads are used, but benchmark doesn't really have control
over that.

Signed-off-by: Burt P <pburt0@gmail.com>
  • Loading branch information...
bp0 authored and lpereira committed Sep 5, 2019
1 parent 9b17b17 commit c982d4e344f06a3b147d05de9476e7fcd7c9a5ac
Showing with 64 additions and 64 deletions.
  1. +2 −0 includes/benchmark.h
  2. +24 −9 modules/benchmark/bench_results.c
  3. +3 −3 modules/benchmark/benches.c
  4. +34 −51 modules/benchmark/sysbench.c
  5. +1 −1 test/just_bench.sh
@@ -4,6 +4,8 @@
#include "hardinfo.h"
#include "util_sysobj.h" /* for SEQ() */

#define BENCH_PTR_BITS ((unsigned int)sizeof(void*) * 8)

extern ProgramParameters params;

enum {
@@ -33,6 +33,7 @@ typedef struct {
int cores;
int threads;
char *mid;
int ptr_bits; /* 32, 64... BENCH_PTR_BITS; 0 for unspecified */
int machine_data_version;
} bench_machine;

@@ -151,6 +152,7 @@ bench_machine *bench_machine_this() {

m = bench_machine_new();
if (m) {
m->ptr_bits = BENCH_PTR_BITS;
m->board = module_call_method("devices::getMotherboard");
m->cpu_name = module_call_method("devices::getProcessorName");
m->cpu_desc = module_call_method("devices::getProcessorDesc");
@@ -278,6 +280,8 @@ bench_result *bench_result_benchmarkconf(const char *section, const char *key, c
b->machine->gpu_desc = strdup(values[11]);
if (vl >= 13)
b->machine->machine_data_version = atoi(values[12]);
if (vl >= 14)
b->machine->ptr_bits = atoi(values[13]);
b->legacy = 0;
} else if (vl >= 2) {
b->bvalue.result = atof(values[0]);
@@ -367,7 +371,7 @@ char *bench_result_benchmarkconf_line(bench_result *b) {
char *bv = bench_value_to_str(b->bvalue);

#define prep_str(s) (s ? (char*)auto_free(gg_key_file_parse_string_as_value(s, '|')) : "")
char *ret = g_strdup_printf("%s=%s|%d|%s|%s|%s|%s|%d|%d|%d|%d|%s|%s|%d\n",
char *ret = g_strdup_printf("%s=%s|%d|%s|%s|%s|%s|%d|%d|%d|%d|%s|%s|%d|%d\n",
b->machine->mid, bv, b->bvalue.threads_used,
prep_str(b->machine->board),
prep_str(b->machine->cpu_name),
@@ -377,7 +381,8 @@ char *bench_result_benchmarkconf_line(bench_result *b) {
b->machine->processors, b->machine->cores, b->machine->threads,
prep_str(b->machine->ogl_renderer),
prep_str(b->machine->gpu_desc),
b->machine->machine_data_version // [12]
b->machine->machine_data_version, // [12]
b->machine->ptr_bits // [13]
);

free(cpu_config);
@@ -393,6 +398,9 @@ static char *bench_result_more_info_less(bench_result *b) {
char bench_str[256] = "";
if (b->bvalue.revision >= 0)
snprintf(bench_str, 127, "%d", b->bvalue.revision);
char bits[24] = "";
if (b->machine->ptr_bits)
snprintf(bits, 23, _("%d-bit"), b->machine->ptr_bits);

char *ret = g_strdup_printf("[%s]\n"
/* threads */ "%s=%d\n"
@@ -409,13 +417,14 @@ static char *bench_result_more_info_less(bench_result *b) {
/* threads */ "%s=%d\n"
/* gpu desc */ "%s=%s\n"
/* ogl rend */ "%s=%s\n"
/* mem */ "%s=%s\n",
/* mem */ "%s=%s\n"
/* bits */ "%s=%s\n",
_("Benchmark Result"),
_("Threads"), b->bvalue.threads_used,
_("Elapsed Time"), b->bvalue.elapsed_time, _("seconds"),
*bench_str ? _("Revision") : _("#Revision"), bench_str,
*b->bvalue.extra ? _("Extra Information") : _("#Extra"), b->bvalue.extra,
*b->bvalue.user_note ? _("User Note") : _("#User Note"), b->bvalue.user_note,
*bench_str ? _("Revision") : "#Revision", bench_str,
*b->bvalue.extra ? _("Extra Information") : "#Extra", b->bvalue.extra,
*b->bvalue.user_note ? _("User Note") : "#User Note", b->bvalue.user_note,
b->legacy ? problem_marker() : "",
b->legacy ? _("Note") : "#Note",
b->legacy ? _("This result is from an old version of HardInfo. Results might not be comparable to current version. Some details are missing.") : "",
@@ -427,7 +436,8 @@ static char *bench_result_more_info_less(bench_result *b) {
_("Threads Available"), b->machine->threads,
_("GPU"), (b->machine->gpu_desc != NULL) ? b->machine->gpu_desc : _(unk),
_("OpenGL Renderer"), (b->machine->ogl_renderer != NULL) ? b->machine->ogl_renderer : _(unk),
_("Memory"), memory
_("Memory"), memory,
b->machine->ptr_bits ? _("Pointer Size"): "#AddySize", bits
);
free(memory);
return ret;
@@ -438,6 +448,9 @@ static char *bench_result_more_info_complete(bench_result *b) {
strncpy(bench_str, b->name, 127);
if (b->bvalue.revision >= 0)
snprintf(bench_str + strlen(bench_str), 127, " (r%d)", b->bvalue.revision);
char bits[24] = "";
if (b->machine->ptr_bits)
snprintf(bits, 23, _("%d-bit"), b->machine->ptr_bits);

return g_strdup_printf("[%s]\n"
/* bench name */"%s=%s\n"
@@ -456,6 +469,7 @@ static char *bench_result_more_info_complete(bench_result *b) {
/* gpu desc */ "%s=%s\n"
/* ogl rend */ "%s=%s\n"
/* mem */ "%s=%d %s\n"
/* bits */ "%s=%s\n"
"%s=%d\n"
"[%s]\n"
/* mid */ "%s=%s\n"
@@ -465,8 +479,8 @@ static char *bench_result_more_info_complete(bench_result *b) {
_("Threads"), b->bvalue.threads_used,
_("Result"), b->bvalue.result,
_("Elapsed Time"), b->bvalue.elapsed_time, _("seconds"),
*b->bvalue.extra ? _("Extra Information") : _("#Extra"), b->bvalue.extra,
*b->bvalue.user_note ? _("User Note") : _("#User Note"), b->bvalue.user_note,
*b->bvalue.extra ? _("Extra Information") : "#Extra", b->bvalue.extra,
*b->bvalue.user_note ? _("User Note") : "#User Note", b->bvalue.user_note,
b->legacy ? problem_marker() : "",
b->legacy ? _("Note") : "#Note",
b->legacy ? _("This result is from an old version of HardInfo. Results might not be comparable to current version. Some details are missing.") : "",
@@ -479,6 +493,7 @@ static char *bench_result_more_info_complete(bench_result *b) {
_("GPU"), (b->machine->gpu_desc != NULL) ? b->machine->gpu_desc : _(unk),
_("OpenGL Renderer"), (b->machine->ogl_renderer != NULL) ? b->machine->ogl_renderer : _(unk),
_("Memory"), b->machine->memory_kiB, _("kiB"),
b->machine->ptr_bits ? _("Pointer Size"): "#AddySize", bits,
".machine_data_version", b->machine->machine_data_version,
_("Handles"),
_("mid"), b->machine->mid,
@@ -101,11 +101,11 @@ static ModuleEntry entries[] = {
[BENCHMARK_SBCPU_ALL] =
{N_("SysBench CPU (Multi-thread)"), "processor.png", callback_benchmark_sbcpu_all, scan_benchmark_sbcpu_all, MODULE_FLAG_NONE},
[BENCHMARK_SBCPU_QUAD] =
{N_("#SysBench CPU (Four threads)"), "processor.png", callback_benchmark_sbcpu_quad, scan_benchmark_sbcpu_quad, MODULE_FLAG_HIDE},
{N_("SysBench CPU (Four threads)"), "processor.png", callback_benchmark_sbcpu_quad, scan_benchmark_sbcpu_quad, MODULE_FLAG_HIDE},
[BENCHMARK_MEMORY_SINGLE] =
{N_("#SysBench Memory (Single-thread)"), "memory.png", callback_benchmark_memory_single, scan_benchmark_memory_single, MODULE_FLAG_HIDE},
{N_("SysBench Memory (Single-thread)"), "memory.png", callback_benchmark_memory_single, scan_benchmark_memory_single, MODULE_FLAG_NONE},
[BENCHMARK_MEMORY_DUAL] =
{N_("#SysBench Memory (Two threads)"), "memory.png", callback_benchmark_memory_dual, scan_benchmark_memory_dual, MODULE_FLAG_HIDE},
{N_("SysBench Memory (Two threads)"), "memory.png", callback_benchmark_memory_dual, scan_benchmark_memory_dual, MODULE_FLAG_HIDE},
[BENCHMARK_MEMORY_QUAD] =
{N_("SysBench Memory"), "memory.png", callback_benchmark_memory_quad, scan_benchmark_memory_quad, MODULE_FLAG_NONE},
#if !GTK_CHECK_VERSION(3,0,0)
@@ -20,6 +20,8 @@
#include "hardinfo.h"
#include "benchmark.h"

#define STATMSG "Performing Alexey Kopytov's sysbench memory benchmark"

/* known to work with:
* sysbench 0.4.12 --> r:4012
* sysbench 1.0.11 --> r:1000011
@@ -63,7 +65,7 @@ int sysbench_version() {
return ret;
}

static gboolean sysbench_run(struct sysbench_ctx *ctx) {
static gboolean sysbench_run(struct sysbench_ctx *ctx, int expecting_version) {
gboolean spawned;
gchar *out, *err, *p, *next_nl;

@@ -81,8 +83,9 @@ static gboolean sysbench_run(struct sysbench_ctx *ctx) {
snprintf(ctx->r.extra, 255, "--time=%d %s", ctx->max_time, ctx->parms_test);
util_compress_space(ctx->r.extra);

int expecting = sysbench_version();
if (expecting < 1000000) {
if (!expecting_version)
expecting_version = sysbench_version();
if (expecting_version < 1000000) {
/* v0.x.x: sysbench [general-options]... --test=<test-name> [test-options]... command */
cmd_line = g_strdup_printf("sysbench --num-threads=%d --max-time=%d --test=%s %s run", ctx->threads, ctx->max_time, ctx->test, ctx->parms_test);
} else {
@@ -171,66 +174,46 @@ static gboolean sysbench_run(struct sysbench_ctx *ctx) {
return 0;
}

void benchmark_memory_single(void) {
void benchmark_memory_run(int threads, int result_index) {
struct sysbench_ctx ctx = {
.test = "memory",
.threads = 1,
.parms_test =
" --memory-block-size=1K"
" --memory-total-size=3056M"
" --memory-scope=global"
" --memory-hugetlb=off"
" --memory-oper=write"
" --memory-access-mode=seq",
.threads = threads,
.parms_test = "",
.r = EMPTY_BENCH_VALUE};

shell_view_set_enabled(FALSE);
shell_status_update("Performing Alexey Kopytov's sysbench memory benchmark (single thread)...");

sysbench_run(&ctx);
bench_results[BENCHMARK_MEMORY_SINGLE] = ctx.r;
}

void benchmark_memory_dual(void) {
struct sysbench_ctx ctx = {
.test = "memory",
.threads = 2,
.parms_test =
int sbv = sysbench_version();
if (BENCH_PTR_BITS > 32 && sbv >= 1000011) {
ctx.parms_test =
" --memory-block-size=1K"
" --memory-total-size=3056M"
" --memory-total-size=100G"
" --memory-scope=global"
" --memory-hugetlb=off"
" --memory-oper=write"
" --memory-access-mode=seq",
.r = EMPTY_BENCH_VALUE};

shell_view_set_enabled(FALSE);
shell_status_update("Performing Alexey Kopytov's sysbench memory benchmark (two threads)...");

sysbench_run(&ctx);
bench_results[BENCHMARK_MEMORY_DUAL] = ctx.r;
}

void benchmark_memory_quad(void) {
struct sysbench_ctx ctx = {
.test = "memory",
.threads = 4,
.parms_test =
" --memory-access-mode=seq";
} else {
/* safer set */
ctx.parms_test =
" --memory-block-size=1K"
" --memory-total-size=3056M"
" --memory-scope=global"
" --memory-hugetlb=off"
" --memory-oper=write"
" --memory-access-mode=seq",
.r = EMPTY_BENCH_VALUE};
" --memory-access-mode=seq";
}

shell_view_set_enabled(FALSE);
shell_status_update("Performing Alexey Kopytov's sysbench memory benchmark (four threads)...");
char msg[128] = "";
snprintf(msg, 128, "%s (threads: %d)", STATMSG, threads);
shell_status_update(msg);

sysbench_run(&ctx);
bench_results[BENCHMARK_MEMORY_QUAD] = ctx.r;
sysbench_run(&ctx, sbv);
bench_results[result_index] = ctx.r;
}

void benchmark_memory_single(void) { benchmark_memory_run(1, BENCHMARK_MEMORY_SINGLE); }
void benchmark_memory_dual(void) { benchmark_memory_run(2, BENCHMARK_MEMORY_DUAL); }
void benchmark_memory_quad(void) { benchmark_memory_run(4, BENCHMARK_MEMORY_QUAD); }

void benchmark_sbcpu_single(void) {
struct sysbench_ctx ctx = {
.test = "cpu",
@@ -240,9 +223,9 @@ void benchmark_sbcpu_single(void) {
.r = EMPTY_BENCH_VALUE};

shell_view_set_enabled(FALSE);
shell_status_update("Performing Alexey Kopytov's sysbench CPU benchmark (single thread)...");
shell_status_update(STATMSG " (single thread)...");

sysbench_run(&ctx);
sysbench_run(&ctx, 0);
bench_results[BENCHMARK_SBCPU_SINGLE] = ctx.r;
}

@@ -257,9 +240,9 @@ void benchmark_sbcpu_all(void) {
.r = EMPTY_BENCH_VALUE};

shell_view_set_enabled(FALSE);
shell_status_update("Performing Alexey Kopytov's sysbench CPU benchmark (Multi-thread)...");
shell_status_update(STATMSG " (Multi-thread)...");

sysbench_run(&ctx);
sysbench_run(&ctx, 0);
bench_results[BENCHMARK_SBCPU_ALL] = ctx.r;
}

@@ -272,8 +255,8 @@ void benchmark_sbcpu_quad(void) {
.r = EMPTY_BENCH_VALUE};

shell_view_set_enabled(FALSE);
shell_status_update("Performing Alexey Kopytov's sysbench CPU benchmark (Four thread)...");
shell_status_update(STATMSG " (Four thread)...");

sysbench_run(&ctx);
sysbench_run(&ctx, 0);
bench_results[BENCHMARK_SBCPU_QUAD] = ctx.r;
}
@@ -27,7 +27,7 @@ if [ ! -z `which sysbench` ]; then
do_hi_bench "SysBench CPU (Single-thread)"
do_hi_bench "SysBench CPU (Multi-thread)"
#do_hi_bench "SysBench CPU (Four threads)"
#do_hi_bench "SysBench Memory (Single-thread)"
do_hi_bench "SysBench Memory (Single-thread)"
#do_hi_bench "SysBench Memory (Two threads)"
do_hi_bench "SysBench Memory"
fi

0 comments on commit c982d4e

Please sign in to comment.
You can’t perform that action at this time.