Skip to content

Restore lost concurrency when scanning for triggers#3444

Merged
tilacog merged 1 commit intomasterfrom
tiago/revert-concurrency-loss
Apr 8, 2022
Merged

Restore lost concurrency when scanning for triggers#3444
tilacog merged 1 commit intomasterfrom
tiago/revert-concurrency-loss

Conversation

@tilacog
Copy link
Copy Markdown
Contributor

@tilacog tilacog commented Apr 7, 2022

This PR aims to improve performance issues introduced in #3373.

It reestablishes concurrency when scanning for triggers in a block range and resolving a block hash.

@tilacog tilacog requested a review from leoyvens April 7, 2022 22:26
Comment on lines +1365 to +1371
// Join on triggers and block hash resolution
let (triggers, to_hash) = futures03::join!(trigger_futs.try_concat(), to_hash_fut);

// Unpack and handle possible errors in the previously joined futures
let triggers =
triggers.with_context(|| format!("Failed to obtain triggers for block {}", to))?;
let to_hash = to_hash.with_context(|| format!("Failed to infer hash for block {}", to))?;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I decided not to use try_join! as it discards one error if the two operations fail.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Well, this will discard the to_hash error if both fail, so it's not so different from try_join, which would be fine imo.

Copy link
Copy Markdown
Contributor Author

@tilacog tilacog Apr 8, 2022

Choose a reason for hiding this comment

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

You have a point.

I was reluctant to use try_join because it would only return the fastest error to resolve and discard the slowest, so I was concerned about indeterminism in this case.

If omitting a second error situation isn't a problem, I can change this to use try_join or just leave it as it is.
If not, I can rewrite this to provide a combined error message for when we have two error values.

Which one do you think would be preferable?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

interesting point about determinism. I think we can keep this as-is then.

@tilacog tilacog merged commit 8470ba1 into master Apr 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants