Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@maoueh
Copy link
Contributor

@maoueh maoueh commented Dec 17, 2021

When a filter is empty, it means it cannot match anything. By guarding the parsing of the triggers upfront, we avoid looping through lot's of element in the blocks, this is especially true for full blocks that contain all the transactions.

Fixes #3080

When a filter is empty, it means it cannot match anything. By guarding the parsing of the triggers upfront, we avoid looping through lot's of element in the blocks, this is especially true for full blocks that contain all the transactions.

Fixes #3080
When a filter is empty, it means it cannot match anything. By guarding the parsing of the triggers upfront, we avoid looping through lot's of element in the blocks, this is especially true for full blocks that contain all the transactions.

Remove a `clone()` that can be delayed to later at the same time.

Fixes #3080
@maoueh maoueh force-pushed the maoueh/feature/parse_triggers_only_when_required branch from b487634 to b884cf9 Compare December 18, 2021 00:39
}
}

impl From<&EthereumBlockFilter> for EthereumCallFilter {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Generally if a From<&T> impl is effectively cloning T internally as this is doing, I prefer having only the From<T> impl and requiring the caller to clone if they want to use it on an &T, to make the potential cost of cloning explicit.

Feel free to merge after addressing this.

Copy link
Contributor Author

@maoueh maoueh Dec 21, 2021

Choose a reason for hiding this comment

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

It's not exact that it's cloning T directly, it's actually cloning only what is required for the transformation to work. I don't see why cloning EthereumBlockFilter would be necessary when we only care about some parts of the actual EthereumBlockFilter struct. The overprice is not quite big here, but still present. We have other occurrences of this pattern in other location like BlockPtr::From<&EthereumBlock>.

I do understand the concern about the implicit "copy", but any From<> calls does some kind of allocation, so it's already implied there is some allocations cost when dealing with From<> calls.

Copy link
Collaborator

Choose a reason for hiding this comment

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

True that this can be implemented more efficiently on &T since it only clones the necessary bits, but it does pessimize the implementation for T since that now clones when previously it moved the addresses. Is From< EthereumBlockFilter> even used anywhere? If not we can just remove it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I see the point about the other version being now less efficient. I removed it and every places now uses the reference version.

@maoueh maoueh merged commit 4d4947e into master Dec 22, 2021
@maoueh maoueh deleted the maoueh/feature/parse_triggers_only_when_required branch December 22, 2021 03:45
kamilkisiela pushed a commit that referenced this pull request Jan 5, 2022
When a filter is empty, it means it cannot match anything. By guarding the parsing of the triggers upfront, we avoid looping through lot's of element in the blocks, this is especially true for full blocks that contain all the transactions.

Remove a `clone()` that can be delayed to later at the same time.

Fixes #3080
kamilkisiela pushed a commit that referenced this pull request Jan 12, 2022
When a filter is empty, it means it cannot match anything. By guarding the parsing of the triggers upfront, we avoid looping through lot's of element in the blocks, this is especially true for full blocks that contain all the transactions.

Remove a `clone()` that can be delayed to later at the same time.

Fixes #3080
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.

firehose_triggers_in_block should add conditional judgment before filter

3 participants