New speed test options

This commit is contained in:
Andrea Mazzoleni 2026-01-08 17:28:35 +01:00
parent 96a70ac77e
commit 00dc3e6a48
4 changed files with 46 additions and 21 deletions

View file

@ -10,6 +10,13 @@ SnapRAID HISTORY
* Added documentation of the tags used in the log file in the new
snapraid_log manpage.
* Added manual translations in multiple languages.
* Added new undocumented options that affect the -T, --speed-test:
--speed-test-period MS, specifies how many milliseconds to test each single
feature in the speed test. Default 1000.
--speed-test-disks-number DISKS, specifies how many disks to use in the
speed test. Default 8.
--speed-test-blocks-size KB, specifies the block size in kibibytes (1024)
for the speed test. Default 256.
13.0 2025/10
============

View file

@ -679,6 +679,9 @@ void config(char* conf, size_t conf_size, const char* argv0)
#define OPT_TEST_SKIP_SPACE_HOLDER 303
#define OPT_TEST_FORMAT 304
#define OPT_TEST_SKIP_MULTI_SCAN 305
#define OPT_TEST_SPEED_PERIOD 307
#define OPT_TEST_SPEED_DISKS_NUMBER 308
#define OPT_TEST_SPEED_BLOCKS_SIZE 309
#if HAVE_GETOPT_LONG
static struct option long_options[] = {
@ -708,6 +711,9 @@ static struct option long_options[] = {
{ "audit-only", 0, 0, 'a' },
{ "pre-hash", 0, 0, 'h' },
{ "speed-test", 0, 0, 'T' }, /* undocumented speed test command */
{ "speed-test-period", 1, 0, OPT_TEST_SPEED_PERIOD }, /* for how many milliseconds test each feature. Default 1000. */
{ "speed-test-disks-number", 1, 0, OPT_TEST_SPEED_DISKS_NUMBER }, /* how many disk number uses in the speed test. Default 8. */
{ "speed-test-blocks-size", 1, 0, OPT_TEST_SPEED_BLOCKS_SIZE }, /* how big in kBytes should be the blocks in the speed test. Default 256. */
{ "gen-conf", 1, 0, 'C' },
{ "verbose", 0, 0, 'v' },
{ "quiet", 0, 0, 'q' },
@ -940,7 +946,9 @@ int snapraid_main(int argc, char* argv[])
const char* gen_conf;
const char* run;
int speedtest;
int period;
int speed_test_period;
int speed_test_disks_number;
int speed_test_blocks_size;
time_t t;
struct tm* tm;
#if HAVE_LOCALTIME_R
@ -960,7 +968,9 @@ int snapraid_main(int argc, char* argv[])
blockcount = 0;
tommy_list_init(&filterlist_file);
tommy_list_init(&filterlist_disk);
period = 1000;
speed_test_period = -1;
speed_test_blocks_size = -1;
speed_test_disks_number = -1;
filter_missing = 0;
filter_error = 0;
plan = SCRUB_AUTO;
@ -1184,6 +1194,15 @@ int snapraid_main(int argc, char* argv[])
case 'T' :
speedtest = 1;
break;
case OPT_TEST_SPEED_PERIOD :
speed_test_period = atoi(optarg);
break;
case OPT_TEST_SPEED_DISKS_NUMBER :
speed_test_disks_number = atoi(optarg);
break;
case OPT_TEST_SPEED_BLOCKS_SIZE :
speed_test_blocks_size = atoi(optarg);
break;
case 'C' :
gen_conf = optarg;
break;
@ -1207,7 +1226,7 @@ int snapraid_main(int argc, char* argv[])
break;
case OPT_TEST_SKIP_DEVICE :
opt.skip_device = 1;
period = 50; /* reduce period of the speed test */
speed_test_period = 50; /* reduce period of the speed test for running the make check */
break;
case OPT_TEST_SKIP_CONTENT_CHECK :
opt.skip_content_check = 1;
@ -1363,7 +1382,7 @@ int snapraid_main(int argc, char* argv[])
random_reseed();
if (speedtest != 0) {
speed(period);
speed(speed_test_period, speed_test_disks_number, speed_test_blocks_size);
os_done();
exit(EXIT_SUCCESS);
}

View file

@ -21,7 +21,7 @@
/****************************************************************************/
/* snapraid */
void speed(int period);
void speed(int period, int disks_number, int blocks_size);
void selftest(void);
int snapraid_main(int argc, char* argv[]);

View file

@ -25,16 +25,6 @@
#include "raid/memory.h"
#include "state.h"
/*
* Size of the blocks to test.
*/
#define TEST_SIZE (256 * KIBI)
/*
* Number of data blocks to test.
*/
#define TEST_COUNT (8)
/**
* Differential us of two timeval.
*/
@ -75,7 +65,7 @@ static int64_t diffgettimeofday(struct timeval *start, struct timeval *stop)
*/
static unsigned side_effect;
void speed(int period)
void speed(int period, int nd, int size)
{
struct timeval start;
struct timeval stop;
@ -87,12 +77,21 @@ void speed(int period)
int id[RAID_PARITY_MAX];
int ip[RAID_PARITY_MAX];
int count;
int delta = period >= 1000 ? 10 : 1;
int size = TEST_SIZE;
int nd = TEST_COUNT;
int delta;
int nv;
void *v_alloc;
void **v;
void* v_alloc;
void** v;
if (nd < 0)
nd = 8;
if (size < 0)
size = 256 * KIBI;
else
size *= KIBI;
if (period < 0)
period = 1000;
delta = period >= 1000 ? 10 : 1;
nv = nd + RAID_PARITY_MAX + 1;