Skip to content
This repository was archived by the owner on Nov 6, 2020. It is now read-only.

Commit 87c11ea

Browse files
committed
VerificationQueue don't spawn up extra threads
In the verification queue we spawn up worker threads to do the work. However, if `num-verifiers` is specified we still spawn the maximum number of threads which consume extra memory. There is one catch though when `--scale-verifiers` is specified then we can't do it because all threads are created upon initilization AFAIK. In my opinion, is doesn't to use both `num-verifiers` and `scale-verifiers` they are kind of contradictory!
1 parent cc963d4 commit 87c11ea

File tree

1 file changed

+12
-4
lines changed
  • ethcore/src/verification/queue

1 file changed

+12
-4
lines changed

ethcore/src/verification/queue/mod.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,12 +232,20 @@ impl<K: Kind> VerificationQueue<K> {
232232
let scale_verifiers = config.verifier_settings.scale_verifiers;
233233

234234
let num_cpus = ::num_cpus::get();
235-
let max_verifiers = cmp::min(num_cpus, MAX_VERIFIERS);
236-
let default_amount = cmp::max(1, cmp::min(max_verifiers, config.verifier_settings.num_verifiers));
237-
let state = Arc::new((Mutex::new(State::Work(default_amount)), Condvar::new()));
235+
let cli_max_verifiers = cmp::max(1, config.verifier_settings.num_verifiers);
236+
237+
// if `auto-scaling` is enabled spawn up extra threads as they might be needed
238+
// otherwise just spawn the number of threads specified by the config
239+
let max_verifiers = if scale_verifiers {
240+
cmp::min(num_cpus, MAX_VERIFIERS)
241+
} else {
242+
cmp::min(cli_max_verifiers, cmp::min(num_cpus, MAX_VERIFIERS))
243+
};
244+
245+
let state = Arc::new((Mutex::new(State::Work(cli_max_verifiers)), Condvar::new()));
238246
let mut verifier_handles = Vec::with_capacity(max_verifiers);
239247

240-
debug!(target: "verification", "Allocating {} verifiers, {} initially active", max_verifiers, default_amount);
248+
debug!(target: "verification", "Allocating {} verifiers, {} initially active", max_verifiers, cli_max_verifiers);
241249
debug!(target: "verification", "Verifier auto-scaling {}", if scale_verifiers { "enabled" } else { "disabled" });
242250

243251
for i in 0..max_verifiers {

0 commit comments

Comments
 (0)