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

Don't call mark_as_bad needlessly #648

Merged
merged 1 commit into from
Mar 10, 2016
Merged

Don't call mark_as_bad needlessly #648

merged 1 commit into from
Mar 10, 2016

Conversation

arkpar
Copy link
Collaborator

@arkpar arkpar commented Mar 9, 2016

Profiling shows calls to mark_as_bad take significant time because inside there is a rearrangement of the verification queue even if the list of bad blocks is empty.

@arkpar arkpar added the A0-pleasereview 🤓 Pull request needs code review. label Mar 9, 2016
@gavofyork gavofyork added A8-looksgood 🦄 Pull request is reviewed well. and removed A0-pleasereview 🤓 Pull request needs code review. labels Mar 9, 2016
@@ -404,8 +404,12 @@ impl<V> Client<V> where V: Verifier {

{
let mut block_queue = self.block_queue.write().unwrap();
block_queue.mark_as_bad(&bad_blocks);
block_queue.mark_as_good(&good_blocks);
if !bad_blocks.is_empty() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it worth checking in both places? Why do you check here also?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Inside - to protect from invalid use outside
Outside - to protect from inefficient implementation inside )

Copy link
Collaborator

Choose a reason for hiding this comment

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

I would rather leave comment Inside to explain why it's better not to remove it (or maybe it's possible to write test that empty list should rearrange?)

But LGTM anyway.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

After the rearrange it's the same queue, just some time wasted

tomusdrw added a commit that referenced this pull request Mar 10, 2016
Don't call mark_as_bad needlessly
@tomusdrw tomusdrw merged commit c380380 into master Mar 10, 2016
@debris debris deleted the bq-fix branch March 10, 2016 09:56
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A8-looksgood 🦄 Pull request is reviewed well.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants