Set default max_thread to 256
Current code requires --max_thread to explicitly specify thread count,
and default to 1 thread(which is horrible slow). Change default to 256.
This doesn't mean we will use 256 threads at all times, thread count
is still upper bounded by number of CPU cores.
Test: run ota_from_target_files, make sure >1 thread is used by default
Change-Id: I7e7d91e7329e1aec50df45796ddf8f0fe543e33a
diff --git a/payload_generator/delta_diff_generator.cc b/payload_generator/delta_diff_generator.cc
index 86238f8..eb4e594 100644
--- a/payload_generator/delta_diff_generator.cc
+++ b/payload_generator/delta_diff_generator.cc
@@ -197,7 +197,7 @@
std::vector<PartitionProcessor> partition_tasks{};
auto thread_count = std::min<size_t>(diff_utils::GetMaxThreads(),
config.target.partitions.size());
- if (thread_count > config.max_threads) {
+ if (thread_count > config.max_threads && config.max_threads > 0) {
thread_count = config.max_threads;
}
if (thread_count < 1) {
@@ -205,6 +205,8 @@
}
base::DelegateSimpleThreadPool thread_pool{"partition-thread-pool",
static_cast<int>(thread_count)};
+ LOG(INFO) << "Using " << thread_count << " threads to process "
+ << config.target.partitions.size() << " partitions";
for (size_t i = 0; i < config.target.partitions.size(); i++) {
const PartitionConfig& old_part =
config.is_delta ? config.source.partitions[i] : empty_part;
diff --git a/payload_generator/delta_diff_utils.cc b/payload_generator/delta_diff_utils.cc
index 798f191..549a2b7 100644
--- a/payload_generator/delta_diff_utils.cc
+++ b/payload_generator/delta_diff_utils.cc
@@ -677,9 +677,12 @@
size_t max_threads = GetMaxThreads();
- if (config.max_threads > 0) {
+ if (config.max_threads > 0 && config.max_threads < max_threads) {
max_threads = config.max_threads;
}
+ LOG(INFO) << "Using " << max_threads << " threads to process "
+ << file_delta_processors.size() << " files on partition "
+ << old_part.name;
// Sort the files in descending order based on number of new blocks to make
// sure we start the largest ones first.
diff --git a/payload_generator/generate_delta_main.cc b/payload_generator/generate_delta_main.cc
index 40dae87..7507ff3 100644
--- a/payload_generator/generate_delta_main.cc
+++ b/payload_generator/generate_delta_main.cc
@@ -764,10 +764,9 @@
payload_config.security_patch_level = FLAGS_security_patch_level;
- if (FLAGS_max_threads < 1) {
- FLAGS_max_threads = 1;
+ if (FLAGS_max_threads > 0) {
+ payload_config.max_threads = FLAGS_max_threads;
}
- payload_config.max_threads = FLAGS_max_threads;
if (!FLAGS_partition_timestamps.empty()) {
CHECK(ParsePerPartitionTimestamps(FLAGS_partition_timestamps,
diff --git a/payload_generator/payload_generation_config.h b/payload_generator/payload_generation_config.h
index dc18641..7f107bb 100644
--- a/payload_generator/payload_generation_config.h
+++ b/payload_generator/payload_generation_config.h
@@ -266,7 +266,9 @@
std::string security_patch_level;
- uint32_t max_threads = 1;
+ // This doesn't mean we will use 256 threads, we still upper bound thread
+ // count by number of CPU cores
+ uint32_t max_threads = 256;
std::vector<bsdiff::CompressorType> compressors{
bsdiff::CompressorType::kBZ2, bsdiff::CompressorType::kBrotli};