aboutsummaryrefslogtreecommitdiff
path: root/modules/benchmark
diff options
context:
space:
mode:
authorBurt P <pburt0@gmail.com>2019-09-04 22:10:43 -0500
committerLeandro A. F. Pereira <leandro@hardinfo.org>2019-10-24 07:54:09 -0700
commitc982d4e344f06a3b147d05de9476e7fcd7c9a5ac (patch)
tree46e64f891dd306a5a7e4f18b5b7ec8022651c244 /modules/benchmark
parent9b17b17c56c62bfc1b72b74e5fa623f1ad47955e (diff)
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>
Diffstat (limited to 'modules/benchmark')
-rw-r--r--modules/benchmark/bench_results.c33
-rw-r--r--modules/benchmark/benches.c6
-rw-r--r--modules/benchmark/sysbench.c85
3 files changed, 61 insertions, 63 deletions
diff --git a/modules/benchmark/bench_results.c b/modules/benchmark/bench_results.c
index 04a0e879..2175953b 100644
--- a/modules/benchmark/bench_results.c
+++ b/modules/benchmark/bench_results.c
@@ -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,
diff --git a/modules/benchmark/benches.c b/modules/benchmark/benches.c
index 945cfe15..d147bf0c 100644
--- a/modules/benchmark/benches.c
+++ b/modules/benchmark/benches.c
@@ -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)
diff --git a/modules/benchmark/sysbench.c b/modules/benchmark/sysbench.c
index e848b3c6..9b8a4a38 100644
--- a/modules/benchmark/sysbench.c
+++ b/modules/benchmark/sysbench.c
@@ -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 @@ sysbench_failed:
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;
}