diff --git a/include/chia/phase1.hpp b/include/chia/phase1.hpp index 7813bb56..8d282411 100644 --- a/include/chia/phase1.hpp +++ b/include/chia/phase1.hpp @@ -381,7 +381,7 @@ uint64_t compute_matches( int R_index, int num_threads, } }, "phase1/slice"); - L_sort->read(&read_thread, std::max(num_threads / 2, 2)); + L_sort->read(&read_thread, std::max(num_threads / 2, 2), std::max(num_threads / g_read_thread_divider, 2)); read_thread.close(); match_pool.close(); diff --git a/include/chia/phase2.hpp b/include/chia/phase2.hpp index 3c71e21e..c915ddf5 100644 --- a/include/chia/phase2.hpp +++ b/include/chia/phase2.hpp @@ -24,7 +24,7 @@ void compute_table( int R_index, int num_threads, bitfield* L_used, const bitfield* R_used) { - const int num_threads_read = std::max(num_threads / 4, 2); + const int num_threads_read = std::max(num_threads / g_read_thread_divider, 1); DiskTable R_input(R_table); { diff --git a/include/chia/phase3.hpp b/include/chia/phase3.hpp index e0e268fe..bc4d9c4f 100644 --- a/include/chia/phase3.hpp +++ b/include/chia/phase3.hpp @@ -25,7 +25,8 @@ void compute_stage1(int L_index, int num_threads, DiskTable* R_table = nullptr) { const auto begin = get_wall_time_micros(); - const int num_threads_merge = std::max(num_threads / 4, 1); + const int num_threads_read = std::max(num_threads / g_read_thread_divider, 2); + const int num_threads_merge = std::max(num_threads / 8, 1); struct merge_buffer_t { uint64_t offset = 0; // position offset at buffer[0] @@ -164,11 +165,11 @@ void compute_stage1(int L_index, int num_threads, }, &R_add_2, num_threads_merge, "phase3/merge"); std::thread R_sort_read( - [&mutex, &signal_1, num_threads, L_table, R_sort, R_table, &R_read, &R_is_end]() { + [&mutex, &signal_1, num_threads, num_threads_read, L_table, R_sort, R_table, &R_read, &R_is_end]() { if(R_table) { - R_table->read(&R_read, std::max(num_threads / 4, 2)); + R_table->read(&R_read, std::max(num_threads_read / 2, 1)); } else { - R_sort->read(&R_read, std::max(num_threads / (L_table ? 1 : 2), 1)); + R_sort->read(&R_read, std::max(num_threads / (L_table ? 1 : 2), 1), std::max(num_threads_read / 2, 1)); } R_read.close(); { @@ -179,10 +180,10 @@ void compute_stage1(int L_index, int num_threads, }); if(L_table) { - L_table->read(&L_read_1, std::max(num_threads / 4, 2)); + L_table->read(&L_read_1, std::max(num_threads_read / 2, 1)); L_read_1.close(); } else { - L_sort->read(&L_read, std::max(num_threads / (R_table ? 1 : 2), 1)); + L_sort->read(&L_read, std::max(num_threads / (R_table ? 1 : 2), 1), std::max(num_threads_read / 2, 1)); } L_read.close(); { @@ -439,7 +440,7 @@ uint64_t compute_stage2(int L_index, int num_threads, L_add.take(input); }, "phase3/slice"); - R_sort->read(&R_read, num_threads); + R_sort->read(&R_read, num_threads, std::max(num_threads / g_read_thread_divider, 2)); R_read.close(); // Since we don't have a perfect multiple of EPP entries, this writes the last ones diff --git a/include/chia/phase4.hpp b/include/chia/phase4.hpp index 036e4452..7c971287 100644 --- a/include/chia/phase4.hpp +++ b/include/chia/phase4.hpp @@ -190,7 +190,7 @@ uint64_t compute( FILE* plot_file, const int header_size, p7_threads.take(parks); }, "phase4/read"); - L_sort_7->read(&read_thread, num_threads); + L_sort_7->read(&read_thread, num_threads, std::max(num_threads / g_read_thread_divider, 2)); read_thread.close(); park_data.offset = final_file_writer_3; diff --git a/include/chia/settings.h b/include/chia/settings.h index d9e29783..9482634c 100644 --- a/include/chia/settings.h +++ b/include/chia/settings.h @@ -24,6 +24,12 @@ extern size_t g_read_chunk_size; */ extern size_t g_write_chunk_size; +/* + * Divider for number of read threads. + * default = 4 + */ +extern int g_read_thread_divider; + namespace phase2 { extern int g_thread_multi; } diff --git a/src/chia_plot.cpp b/src/chia_plot.cpp index dc031f52..e0d46a8c 100644 --- a/src/chia_plot.cpp +++ b/src/chia_plot.cpp @@ -246,6 +246,7 @@ int main(int argc, char** argv) "f, farmerkey", "Farmer Public Key (48 bytes)", cxxopts::value(farmer_key_str))( "G, tmptoggle", "Alternate tmpdir/tmpdir2", cxxopts::value(tmptoggle))( "K, rmulti2", "Thread multiplier for P2 (default = 1)", cxxopts::value(phase2::g_thread_multi))( + "R, rtdiv", "Number of read threads divider (default = 4)", cxxopts::value(g_read_thread_divider))( "help", "Print help"); if(argc <= 1) { diff --git a/src/settings.cpp b/src/settings.cpp index ee85b7d5..d60cf1a4 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -11,6 +11,8 @@ size_t g_read_chunk_size = 65536; size_t g_write_chunk_size = 4096; +int g_read_thread_divider = 4; + namespace phase2 { int g_thread_multi = 1; }