bump crossbeam (#10848)

This commit is contained in:
Marek Kotewicz
2019-07-06 16:16:53 +02:00
committed by GitHub
parent 86ef490a94
commit a6e96b052e
5 changed files with 64 additions and 122 deletions

View File

@@ -34,7 +34,7 @@ use externalities::*;
use trace::{self, Tracer, VMTracer};
use types::transaction::{Action, SignedTransaction};
use transaction_ext::Transaction;
use crossbeam;
use crossbeam_utils::thread;
pub use executed::{Executed, ExecutionResult};
#[cfg(debug_assertions)]
@@ -977,11 +977,18 @@ impl<'a, B: 'a + StateBackend> Executive<'a, B> {
if stack_depth != depth_threshold {
self.call_with_stack_depth(params, substate, stack_depth, tracer, vm_tracer)
} else {
crossbeam::scope(|scope| {
scope.builder().stack_size(::std::cmp::max(self.schedule.max_depth.saturating_sub(depth_threshold) * STACK_SIZE_PER_DEPTH, local_stack_size)).spawn(move || {
self.call_with_stack_depth(params, substate, stack_depth, tracer, vm_tracer)
}).expect("Sub-thread creation cannot fail; the host might run out of resources; qed")
}).join().expect("Sub-thread never panics; qed")
thread::scope(|scope| {
let stack_size = cmp::max(self.schedule.max_depth.saturating_sub(depth_threshold) * STACK_SIZE_PER_DEPTH, local_stack_size);
scope.builder()
.stack_size(stack_size)
.spawn(|_| {
self.call_with_stack_depth(params, substate, stack_depth, tracer, vm_tracer)
})
.expect("Sub-thread creation cannot fail; the host might run out of resources; qed")
.join()
})
.expect("Sub-thread never panics; qed")
.expect("Sub-thread never panics; qed")
}
}
@@ -1061,11 +1068,18 @@ impl<'a, B: 'a + StateBackend> Executive<'a, B> {
if stack_depth != depth_threshold {
self.create_with_stack_depth(params, substate, stack_depth, tracer, vm_tracer)
} else {
crossbeam::scope(|scope| {
scope.builder().stack_size(::std::cmp::max(self.schedule.max_depth.saturating_sub(depth_threshold) * STACK_SIZE_PER_DEPTH, local_stack_size)).spawn(move || {
self.create_with_stack_depth(params, substate, stack_depth, tracer, vm_tracer)
}).expect("Sub-thread creation cannot fail; the host might run out of resources; qed")
}).join().expect("Sub-thread never panics; qed")
thread::scope(|scope| {
let stack_size = cmp::max(self.schedule.max_depth.saturating_sub(depth_threshold) * STACK_SIZE_PER_DEPTH, local_stack_size);
scope.builder()
.stack_size(stack_size)
.spawn(|_| {
self.create_with_stack_depth(params, substate, stack_depth, tracer, vm_tracer)
})
.expect("Sub-thread creation cannot fail; the host might run out of resources; qed")
.join()
})
.expect("Sub-thread never panics; qed")
.expect("Sub-thread never panics; qed")
}
}

View File

@@ -57,7 +57,7 @@ extern crate account_db;
extern crate ansi_term;
extern crate bn;
extern crate common_types as types;
extern crate crossbeam;
extern crate crossbeam_utils;
extern crate ethabi;
extern crate ethash;
extern crate ethcore_blockchain as blockchain;

View File

@@ -50,7 +50,7 @@ use self::io::SnapshotWriter;
use super::state_db::StateDB;
use super::state::Account as StateAccount;
use crossbeam::scope;
use crossbeam_utils::thread;
use rand::{Rng, rngs::OsRng};
pub use self::error::Error;
@@ -167,9 +167,9 @@ pub fn take_snapshot<W: SnapshotWriter + Send>(
let version = chunker.current_version();
let writer = Mutex::new(writer);
let (state_hashes, block_hashes) = scope(|scope| -> Result<(Vec<H256>, Vec<H256>), Error> {
let (state_hashes, block_hashes) = thread::scope(|scope| -> Result<(Vec<H256>, Vec<H256>), Error> {
let writer = &writer;
let block_guard = scope.spawn(move || {
let block_guard = scope.spawn(move |_| {
chunk_secondary(chunker, chain, block_hash, writer, p)
});
@@ -181,7 +181,7 @@ pub fn take_snapshot<W: SnapshotWriter + Send>(
let mut state_guards = Vec::with_capacity(num_threads as usize);
for thread_idx in 0..num_threads {
let state_guard = scope.spawn(move || -> Result<Vec<H256>, Error> {
let state_guard = scope.spawn(move |_| -> Result<Vec<H256>, Error> {
let mut chunk_hashes = Vec::new();
for part in (thread_idx..SNAPSHOT_SUBPARTS).step_by(num_threads) {
@@ -205,7 +205,7 @@ pub fn take_snapshot<W: SnapshotWriter + Send>(
debug!(target: "snapshot", "Took a snapshot of {} accounts", p.accounts.load(Ordering::SeqCst));
Ok((state_hashes, block_hashes))
})?;
}).expect("Sub-thread never panics; qed")?;
info!(target: "snapshot", "produced {} state chunks and {} block chunks.", state_hashes.len(), block_hashes.len());