diff --git a/cmdline/io.c b/cmdline/io.c index ec78170a..3eff7286 100644 --- a/cmdline/io.c +++ b/cmdline/io.c @@ -72,7 +72,7 @@ void io_init(struct snapraid_io* io, struct snapraid_state* state, allocated += state->block_size * buffer_max; } - msg_progress("Using %u MiB of memory for the MT buffers.\n", (unsigned)(allocated / (1024 * 1024))); + msg_progress("Using %u MiB of memory for the IO cache.\n", (unsigned)(allocated / MEBI)); if (parity_writer) { io->reader_max = handle_max; diff --git a/cmdline/io.h b/cmdline/io.h index 5e64ab2b..b3a2e956 100644 --- a/cmdline/io.h +++ b/cmdline/io.h @@ -30,14 +30,14 @@ * * This is the scrub performance on my machine with different buffers: * - * 1 - 380 MiB/s, CPU 26%, speed 100% [SnapRAID 9.2] - * 2 - 426 MiB/s, CPU 46%, speed 112% - * 4 - 452 MiB/s, CPU 54%, speed 118% - * 8 - 487 MiB/s, CPU 60%, speed 128% - * 16 - 505 MiB/s, CPU 63%, speed 132% - * 32 - 520 MiB/s, CPU 64%, speed 136% - * 64 - 524 MiB/s, CPU 65%, speed 137% - * 128 - 525 MiB/s, CPU 66%, speed 138% + * 1 - 380 MB/s, CPU 26%, speed 100% [SnapRAID 9.2] + * 2 - 426 MB/s, CPU 46%, speed 112% + * 4 - 452 MB/s, CPU 54%, speed 118% + * 8 - 487 MB/s, CPU 60%, speed 128% + * 16 - 505 MB/s, CPU 63%, speed 132% + * 32 - 520 MB/s, CPU 64%, speed 136% + * 64 - 524 MB/s, CPU 65%, speed 137% + * 128 - 525 MB/s, CPU 66%, speed 138% */ #define IO_MIN 3 /* required by writers, readers can work also with 2 */ #define IO_MAX 128 diff --git a/cmdline/snapraid.c b/cmdline/snapraid.c index 7ceeb4f1..47d91dd7 100644 --- a/cmdline/snapraid.c +++ b/cmdline/snapraid.c @@ -86,7 +86,7 @@ void memory(void) log_tag("memory:link:%" PRIu64 "\n", (uint64_t)(sizeof(struct snapraid_link))); log_tag("memory:dir:%" PRIu64 "\n", (uint64_t)(sizeof(struct snapraid_dir))); - msg_progress("Using %u MiB of memory for the FileSystem.\n", (unsigned)(malloc_counter_get() / (1024 * 1024))); + msg_progress("Using %u MiB of memory for the FileSystem.\n", (unsigned)(malloc_counter_get() / MEBI)); } /****************************************************************************/ diff --git a/cmdline/speed.c b/cmdline/speed.c index eb75d7ec..f5ecf785 100644 --- a/cmdline/speed.c +++ b/cmdline/speed.c @@ -28,7 +28,7 @@ /* * Size of the blocks to test. */ -#define TEST_SIZE (256 * 1024) +#define TEST_SIZE (256 * KIBI) /* * Number of data blocks to test. @@ -160,9 +160,9 @@ void speed(int period) printf("\n"); - printf("Speed test using %u data buffers of %u bytes, for a total of %u KiB.\n", nd, size, nd * size / 1024); + printf("Speed test using %u data buffers of %u bytes, for a total of %u KiB.\n", nd, size, nd * size / KIBI); printf("Memory blocks have a displacement of %u bytes to improve cache performance.\n", RAID_MALLOC_DISPLACEMENT); - printf("The reported values are the aggregate bandwidth of all data blocks in MiB/s,\n"); + printf("The reported values are the aggregate bandwidth of all data blocks in MB/s,\n"); printf("not counting parity blocks.\n"); printf("\n"); diff --git a/cmdline/state.c b/cmdline/state.c index 9ef9e49f..1373e39c 100644 --- a/cmdline/state.c +++ b/cmdline/state.c @@ -143,7 +143,7 @@ void state_init(struct snapraid_state* state) state->autosave = 0; state->need_write = 0; state->checked_read = 0; - state->block_size = 256 * 1024; /* default 256 KiB */ + state->block_size = 256 * KIBI; /* default 256 KiB */ state->raid_mode = RAID_MODE_CAUCHY; state->file_mode = MODE_SEQUENTIAL; for (l = 0; l < LEV_MAX; ++l) { @@ -581,7 +581,7 @@ void state_config(struct snapraid_state* state, const char* path, const char* co exit(EXIT_FAILURE); /* LCOV_EXCL_STOP */ } - if (state->block_size > 16 * 1024) { + if (state->block_size > 16 * KIBI) { /* LCOV_EXCL_START */ log_fatal("Too big 'blocksize' specification in '%s' at line %u\n", path, line); exit(EXIT_FAILURE); @@ -594,7 +594,7 @@ void state_config(struct snapraid_state* state, const char* path, const char* co exit(EXIT_FAILURE); /* LCOV_EXCL_STOP */ } - state->block_size *= 1024; + state->block_size *= KIBI; } else if (lev_config_scan(tag, &level, &state->raid_mode) == 0) { char device[PATH_MAX]; char* slash; @@ -2378,7 +2378,7 @@ static void state_read_content(struct snapraid_state* state, const char* path, S /* LCOV_EXCL_START */ decoding_error(path, f); log_fatal("Mismatching 'blocksize' specification in the content file!\n"); - log_fatal("Please restore the 'blocksize' value in the configuration file to '%u'\n", blksize / 1024); + log_fatal("Please restore the 'blocksize' value in the configuration file to '%u'\n", blksize / KIBI); exit(EXIT_FAILURE); /* LCOV_EXCL_STOP */ } @@ -3965,7 +3965,7 @@ int state_progress(struct snapraid_state* state, block_off_t blockpos, block_off delta_tick_total = tick_total - state->progress_tick_total[oldest]; delta_tick_cpu = tick_cpu - state->progress_tick_cpu[oldest]; - /* estimate the speed in MiB/s */ + /* estimate the speed in MB/s */ if (delta_time != 0) out_speed = (unsigned)(delta_size / MEGA / delta_time); @@ -3982,9 +3982,9 @@ int state_progress(struct snapraid_state* state, block_off_t blockpos, block_off log_tag("run:pos:%u:%u:%" PRIu64 ":%u:%u:%u:%u:%" PRIu64 "\n", blockpos, countpos, countsize, out_perc, out_eta, out_speed, out_cpu, (uint64_t)elapsed); log_flush(); } else { - msg_bar("%u%%, %u MiB", out_perc, (unsigned)(countsize / MEGA)); + msg_bar("%u%%, %u MB", out_perc, (unsigned)(countsize / MEGA)); if (out_speed) - msg_bar(", %u MiB/s", out_speed); + msg_bar(", %u MB/s", out_speed); msg_bar(", CPU %u%%", out_cpu); if (out_eta) msg_bar(", %u:%02u ETA", out_eta / 60, out_eta % 60); @@ -4115,7 +4115,7 @@ void generate_configuration(const char* path) printf("# Configuration file generated from %s\n", path); printf("\n"); printf("# Use this blocksize\n"); - printf("blocksize %u\n", state.block_size / 1024); + printf("blocksize %u\n", state.block_size / KIBI); printf("\n"); for (i = 0; i < state.level; ++i) { printf("# Set the correct path for the %s file\n", lev_name(i)); diff --git a/cmdline/state.h b/cmdline/state.h index e0491822..721bde4e 100644 --- a/cmdline/state.h +++ b/cmdline/state.h @@ -44,9 +44,14 @@ const char* lev_config_name(unsigned level); /** * Units for disk space. */ +#define KILO (1000) #define MEGA (1000 * 1000) #define GIGA (1000 * 1000 * 1000) #define TERA (1000 * 1000 * 1000 * 1000LL) +#define KIBI (1024) +#define MEBI (1024 * 1024) +#define GIBI (1024 * 1024 * 1024) +#define TEBI (1024 * 1024 * 1024 * 1024LL) /** * File modes. diff --git a/cmdline/stream.c b/cmdline/stream.c index 31911e3d..c5ced0c7 100644 --- a/cmdline/stream.c +++ b/cmdline/stream.c @@ -24,7 +24,7 @@ /****************************************************************************/ /* stream */ -unsigned STREAM_SIZE = 1024 * 64; +unsigned STREAM_SIZE = 64 * 1024; STREAM* sopen_read(const char* file) {