Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Asynchronous Block Download and Verification #4365

Merged
merged 9 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 57 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,13 @@ check: setup-ckb-test ## Runs all of the compiler's checks.
build: ## Build binary with release profile.
cargo build ${VERBOSE} --release

.PHONY: build-for-profiling-without-debug-symbols
build-for-profiling-without-debug-symbols: ## Build binary with for profiling without debug symbols.
JEMALLOC_SYS_WITH_MALLOC_CONF="prof:true" cargo build ${VERBOSE} --release --features "profiling"
.PHONY: profiling
profiling: ## Build binary with for profiling without debug symbols.
JEMALLOC_SYS_WITH_MALLOC_CONF="prof:true" cargo build ${VERBOSE} --profile prod --features "with_sentry,with_dns_seeding,profiling"

.PHONY: build-for-profiling
.PHONY: profiling-with-debug-symbols
build-for-profiling: ## Build binary with for profiling.
devtools/release/make-with-debug-symbols build-for-profiling-without-debug-symbols
devtools/release/make-with-debug-symbols profiling

.PHONY: prod
prod: ## Build binary for production release.
Expand Down
42 changes: 30 additions & 12 deletions benches/benches/benchmarks/always_success.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fn bench(c: &mut Criterion) {
(0..20).for_each(|_| {
let block = gen_always_success_block(&mut blocks, &parent, shared2);
chain2
.internal_process_block(
.blocking_process_block_with_switch(
Arc::new(block.clone()),
Switch::DISABLE_ALL,
)
Expand All @@ -44,7 +44,10 @@ fn bench(c: &mut Criterion) {
|(chain, blocks)| {
blocks.into_iter().skip(1).for_each(|block| {
chain
.internal_process_block(Arc::new(block), Switch::DISABLE_EXTENSION)
.blocking_process_block_with_switch(
Arc::new(block),
Switch::DISABLE_EXTENSION,
)
.expect("process block OK");
});
},
Expand Down Expand Up @@ -77,14 +80,14 @@ fn bench(c: &mut Criterion) {
(0..5).for_each(|i| {
let block = gen_always_success_block(&mut blocks, &parent, shared2);
chain2
.internal_process_block(
.blocking_process_block_with_switch(
Arc::new(block.clone()),
Switch::DISABLE_ALL,
)
.expect("process block OK");
if i < 2 {
chain3
.internal_process_block(
.blocking_process_block_with_switch(
Arc::new(block.clone()),
Switch::DISABLE_ALL,
)
Expand All @@ -96,7 +99,7 @@ fn bench(c: &mut Criterion) {
(0..2).for_each(|_| {
let block = gen_always_success_block(&mut blocks, &parent, shared3);
chain3
.internal_process_block(
.blocking_process_block_with_switch(
Arc::new(block.clone()),
Switch::DISABLE_ALL,
)
Expand All @@ -110,15 +113,18 @@ fn bench(c: &mut Criterion) {
.take(5)
.for_each(|block| {
chain1
.internal_process_block(Arc::new(block), Switch::DISABLE_ALL)
.blocking_process_block_with_switch(
Arc::new(block),
Switch::DISABLE_ALL,
)
.expect("process block OK");
});
(chain1.clone(), blocks)
},
|(chain, blocks)| {
blocks.into_iter().skip(6).for_each(|block| {
chain
.process_block(Arc::new(block))
.blocking_process_block(Arc::new(block))
.expect("process block OK");
});
},
Expand Down Expand Up @@ -152,11 +158,17 @@ fn bench(c: &mut Criterion) {
let block = gen_always_success_block(&mut blocks, &parent, shared2);
let arc_block = Arc::new(block.clone());
chain2
.internal_process_block(Arc::clone(&arc_block), Switch::DISABLE_ALL)
.blocking_process_block_with_switch(
Arc::clone(&arc_block),
Switch::DISABLE_ALL,
)
.expect("process block OK");
if i < 2 {
chain3
.internal_process_block(arc_block, Switch::DISABLE_ALL)
.blocking_process_block_with_switch(
arc_block,
Switch::DISABLE_ALL,
)
.expect("process block OK");
}
parent = block;
Expand All @@ -165,7 +177,7 @@ fn bench(c: &mut Criterion) {
(0..4).for_each(|_| {
let block = gen_always_success_block(&mut blocks, &parent, shared3);
chain3
.internal_process_block(
.blocking_process_block_with_switch(
Arc::new(block.clone()),
Switch::DISABLE_ALL,
)
Expand All @@ -179,15 +191,21 @@ fn bench(c: &mut Criterion) {
.take(7)
.for_each(|block| {
chain1
.internal_process_block(Arc::new(block), Switch::DISABLE_ALL)
.blocking_process_block_with_switch(
Arc::new(block),
Switch::DISABLE_ALL,
)
.expect("process block OK");
});
(chain1.clone(), blocks)
},
|(chain, blocks)| {
blocks.into_iter().skip(8).for_each(|block| {
chain
.internal_process_block(Arc::new(block), Switch::DISABLE_EXTENSION)
.blocking_process_block_with_switch(
Arc::new(block),
Switch::DISABLE_EXTENSION,
)
.expect("process block OK");
});
},
Expand Down
10 changes: 6 additions & 4 deletions benches/benches/benchmarks/overall.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::benchmarks::util::{create_2out_transaction, create_secp_tx, secp_cell};
use ckb_app_config::NetworkConfig;
use ckb_app_config::{BlockAssemblerConfig, TxPoolConfig};
use ckb_chain::chain::{ChainController, ChainService};
use ckb_chain::{start_chain_services, ChainController};
use ckb_chain_spec::consensus::{ConsensusBuilder, ProposalWindow};
use ckb_dao_utils::genesis_dao_data;
use ckb_jsonrpc_types::JsonBytes;
Expand Down Expand Up @@ -133,8 +133,7 @@ pub fn setup_chain(txs_size: usize) -> (Shared, ChainController) {
let network = dummy_network(&shared);
pack.take_tx_pool_builder().start(network);

let chain_service = ChainService::new(shared.clone(), pack.take_proposal_table());
let chain_controller = chain_service.start(Some("ChainService"));
let chain_controller = start_chain_services(pack.take_chain_services_builder());

(shared, chain_controller)
}
Expand Down Expand Up @@ -219,7 +218,10 @@ fn bench(c: &mut Criterion) {
.expect("header verified");

chain
.internal_process_block(Arc::new(block), Switch::DISABLE_EXTENSION)
.blocking_process_block_with_switch(
Arc::new(block),
Switch::DISABLE_EXTENSION,
)
.expect("process_block");
i -= 1;
}
Expand Down
5 changes: 2 additions & 3 deletions benches/benches/benchmarks/resolve.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::benchmarks::util::create_2out_transaction;
use ckb_app_config::{BlockAssemblerConfig, TxPoolConfig};
use ckb_chain::chain::{ChainController, ChainService};
use ckb_chain::{start_chain_services, ChainController};
use ckb_chain_spec::{ChainSpec, IssuedCell};
use ckb_jsonrpc_types::JsonBytes;
use ckb_resource::Resource;
Expand Down Expand Up @@ -96,8 +96,7 @@ pub fn setup_chain(txs_size: usize) -> (Shared, ChainController) {
.tx_pool_config(tx_pool_config)
.build()
.unwrap();
let chain_service = ChainService::new(shared.clone(), pack.take_proposal_table());
let chain_controller = chain_service.start(Some("ChainService"));
let chain_controller = start_chain_services(pack.take_chain_services_builder());

// FIXME: global cache !!!
let _ret = setup_system_cell_cache(
Expand Down
Loading
Loading