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

add parallel sync buffer as 1000 and will star to execute the block i… #4216

Closed
wants to merge 1 commit into from
Closed
Changes from all 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
15 changes: 11 additions & 4 deletions sync/src/tasks/block_sync_task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,13 +421,15 @@ where
Ok(())
}

async fn find_absent_ancestor(&self, mut block_headers: Vec<BlockHeader>) -> Result<()> {
async fn find_absent_ancestor(&self, mut block_headers: Vec<BlockHeader>) -> Result<u64> {
let mut count: u64 = 0;
loop {
let mut absent_blocks = vec![];
self.find_absent_parent_dag_blocks_for_blocks(block_headers, &mut absent_blocks)?;
if absent_blocks.is_empty() {
return Ok(());
return Ok(count);
}
count = count.saturating_add(absent_blocks.len() as u64);
Comment on lines +424 to +432
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Ensure correct handling of the new return type of find_absent_ancestor

The method find_absent_ancestor now returns Result<u64> instead of Result<()>. Within this file, ensure that all calls to this method correctly handle the new return value, and that the count of absent blocks is appropriately utilized.

block_headers = self.fetch_blocks(absent_blocks).await?;
}
}
Expand All @@ -449,10 +451,15 @@ where
block_header.parents_hash()
);
let fut = async {
self.find_absent_ancestor(vec![block_header.clone()])
let count = self
.find_absent_ancestor(vec![block_header.clone()])
.await?;

if block_header.number() % 10000 == 0
if count == 0 {
return anyhow::Ok(ParallelSign::Continue);
}

if block_header.number() % 1000 == 0
Comment on lines +454 to +462
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Assess the impact of changing the modulus condition from 10000 to 1000

The condition has changed from checking block_header.number() % 10000 == 0 to block_header.number() % 1000 == 0. This increases the frequency at which the associated code block executes. Review whether this change aligns with performance expectations and system requirements.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: 这个可以改成一个常量参数

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.

|| block_header.number() >= self.target.target_id.number()
{
let parallel_execute = DagBlockSender::new(
Expand Down
Loading