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

Rpc: filters performance improvement #20185

Merged
merged 14 commits into from
Oct 14, 2021

Conversation

fanatid
Copy link
Contributor

@fanatid fanatid commented Sep 24, 2021

Closes #20177

@mergify mergify bot added the community Community contribution label Sep 24, 2021
@mergify mergify bot requested a review from a team September 24, 2021 21:38
@fanatid
Copy link
Contributor Author

fanatid commented Sep 24, 2021

CI should be fixed after #20182

@jstarry
Copy link
Member

jstarry commented Sep 24, 2021

There's a temp fix on master already that you can rebase off of too

@codecov
Copy link

codecov bot commented Sep 25, 2021

Codecov Report

Merging #20185 (4864e33) into master (60fe29b) will decrease coverage by 0.0%.
The diff coverage is 64.6%.

@@            Coverage Diff            @@
##           master   #20185     +/-   ##
=========================================
- Coverage    81.9%    81.9%   -0.1%     
=========================================
  Files         495      495             
  Lines      137701   137831    +130     
=========================================
+ Hits       112832   112914     +82     
- Misses      24869    24917     +48     

@fanatid
Copy link
Contributor Author

fanatid commented Oct 7, 2021

@ChrisBellew (sorry for the false ping!) @CriesofCarrots can I help somehow with review? Should I add tests or split PR for adding new enum variants and deprecation?

@CriesofCarrots
Copy link
Contributor

@fanatid , thanks for the ping. Looks like I missed the review notification when I was off the grid in the mountains last weekend. Sorry about that!

Copy link
Contributor

@CriesofCarrots CriesofCarrots left a comment

Choose a reason for hiding this comment

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

This looks great! Just one minor suggestion about a generic DataTooLarge error and nits.

client/src/rpc_filter.rs Outdated Show resolved Hide resolved
client/src/rpc_filter.rs Outdated Show resolved Hide resolved
cli/src/cluster_query.rs Show resolved Hide resolved
client/src/rpc_filter.rs Outdated Show resolved Hide resolved
client/src/rpc_filter.rs Outdated Show resolved Hide resolved
client/src/rpc_filter.rs Outdated Show resolved Hide resolved
@mergify mergify bot requested a review from a team October 7, 2021 16:27
@mergify mergify bot requested a review from a team October 7, 2021 20:06
client/src/rpc_filter.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@t-nelson t-nelson left a comment

Choose a reason for hiding this comment

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

Looking good. Just a few more nits 😉

bs58::decode(&bytes)
use MemcmpEncodedBytes::*;
match &compare.bytes {
Binary(bytes) if bytes.len() > 128 => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's just bump this to the base58 max. No harm in relaxing the limit

client/src/rpc_filter.rs Outdated Show resolved Hide resolved
}
Base58(bytes) if bytes.len() > 175 => Err(RpcFilterError::DataTooLarge),
Base64(bytes) if bytes.len() > 172 => Err(RpcFilterError::DataTooLarge),
Bytes(bytes) if bytes.len() > 128 => Err(RpcFilterError::DataTooLarge),
Copy link
Contributor

Choose a reason for hiding this comment

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

No need to test this since there's no expensive decoding to follow

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why we should not test this value? Test for this value is not only about expensive decoding but also about a performant filter. Or I'm wrong?
Other comments are fixed.

.map_err(RpcFilterError::DecodeError),
Base58(bytes) => {
let bytes = bs58::decode(&bytes).into_vec()?;
if bytes.len() > 128 {
Copy link
Contributor

Choose a reason for hiding this comment

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

This check is unnecessary now. Fine to keep it, but let's name the magic number here too

client/src/rpc_filter.rs Outdated Show resolved Hide resolved
t-nelson
t-nelson previously approved these changes Oct 13, 2021
Copy link
Contributor

@t-nelson t-nelson left a comment

Choose a reason for hiding this comment

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

thanks for addressing! lgtm now once CI's happy*

r+

* looks like a rebase on master will get you past the audit failure

Comment on lines +24 to +39
match &compare.bytes {
Binary(bytes) if bytes.len() > MAX_DATA_BASE58_SIZE => {
Err(RpcFilterError::Base58DataTooLarge)
}
Base58(bytes) if bytes.len() > MAX_DATA_BASE58_SIZE => {
Err(RpcFilterError::DataTooLarge)
}
Base64(bytes) if bytes.len() > MAX_DATA_BASE64_SIZE => {
Err(RpcFilterError::DataTooLarge)
}
Bytes(bytes) if bytes.len() > MAX_DATA_SIZE => {
Err(RpcFilterError::DataTooLarge)
}
_ => Ok(()),
}?;
match &compare.bytes {
Copy link
Contributor

Choose a reason for hiding this comment

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

I still find it more confusing than helpful to have two match statements, esp since the four cases have to handled separately.
All the other changes look great!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

With added changes I find this bit more confusing too 😞 but once MemcmpEncodedBytes::Binary would be removed statements can be merged and simplified a lot!

@mergify mergify bot requested a review from a team October 13, 2021 20:53
@mergify mergify bot dismissed t-nelson’s stale review October 14, 2021 04:37

Pull request has been modified.

@CriesofCarrots
Copy link
Contributor

The CI failure is legit now; looks like there's a test that needs a fixup

@fanatid
Copy link
Contributor Author

fanatid commented Oct 14, 2021

Updated. CI is green now 🎉

@CriesofCarrots
Copy link
Contributor

Thanks for all the work here!

@CriesofCarrots CriesofCarrots merged commit e9a427b into solana-labs:master Oct 14, 2021
mergify bot pushed a commit that referenced this pull request Oct 14, 2021
* Add Base58,Base64,Bytes to MemcmpEncodedBytes

* Rpc: decode memcmp before filtering accounts

* Add deprecated attribute

* Add Memcmp::bytes

* Fix clippy for deprecated

* Another clippy fix

* merge RpcFilterError::DataTooLarge

* add deprecation for Base58DataTooLarge

* change filter data size limit

* strict data size len for base58

* add magic numbers

* fix tests

(cherry picked from commit e9a427b)
@fanatid fanatid deleted the rpc-filter-memcmp branch October 14, 2021 18:50
mergify bot added a commit that referenced this pull request Oct 14, 2021
* Add Base58,Base64,Bytes to MemcmpEncodedBytes

* Rpc: decode memcmp before filtering accounts

* Add deprecated attribute

* Add Memcmp::bytes

* Fix clippy for deprecated

* Another clippy fix

* merge RpcFilterError::DataTooLarge

* add deprecation for Base58DataTooLarge

* change filter data size limit

* strict data size len for base58

* add magic numbers

* fix tests

(cherry picked from commit e9a427b)

Co-authored-by: Kirill Fomichev <[email protected]>
jeffwashington pushed a commit to jeffwashington/solana that referenced this pull request Oct 15, 2021
* Add Base58,Base64,Bytes to MemcmpEncodedBytes

* Rpc: decode memcmp before filtering accounts

* Add deprecated attribute

* Add Memcmp::bytes

* Fix clippy for deprecated

* Another clippy fix

* merge RpcFilterError::DataTooLarge

* add deprecation for Base58DataTooLarge

* change filter data size limit

* strict data size len for base58

* add magic numbers

* fix tests
jeffwashington pushed a commit to jeffwashington/solana that referenced this pull request Oct 15, 2021
* Add Base58,Base64,Bytes to MemcmpEncodedBytes

* Rpc: decode memcmp before filtering accounts

* Add deprecated attribute

* Add Memcmp::bytes

* Fix clippy for deprecated

* Another clippy fix

* merge RpcFilterError::DataTooLarge

* add deprecation for Base58DataTooLarge

* change filter data size limit

* strict data size len for base58

* add magic numbers

* fix tests
mergify bot pushed a commit that referenced this pull request Oct 21, 2021
* Add Base58,Base64,Bytes to MemcmpEncodedBytes

* Rpc: decode memcmp before filtering accounts

* Add deprecated attribute

* Add Memcmp::bytes

* Fix clippy for deprecated

* Another clippy fix

* merge RpcFilterError::DataTooLarge

* add deprecation for Base58DataTooLarge

* change filter data size limit

* strict data size len for base58

* add magic numbers

* fix tests

(cherry picked from commit e9a427b)
mergify bot added a commit that referenced this pull request Oct 22, 2021
* Add Base58,Base64,Bytes to MemcmpEncodedBytes

* Rpc: decode memcmp before filtering accounts

* Add deprecated attribute

* Add Memcmp::bytes

* Fix clippy for deprecated

* Another clippy fix

* merge RpcFilterError::DataTooLarge

* add deprecation for Base58DataTooLarge

* change filter data size limit

* strict data size len for base58

* add magic numbers

* fix tests

(cherry picked from commit e9a427b)

Co-authored-by: Kirill Fomichev <[email protected]>
dankelleher pushed a commit to identity-com/solana that referenced this pull request Nov 24, 2021
* Add Base58,Base64,Bytes to MemcmpEncodedBytes

* Rpc: decode memcmp before filtering accounts

* Add deprecated attribute

* Add Memcmp::bytes

* Fix clippy for deprecated

* Another clippy fix

* merge RpcFilterError::DataTooLarge

* add deprecation for Base58DataTooLarge

* change filter data size limit

* strict data size len for base58

* add magic numbers

* fix tests
frits-metalogix added a commit to identity-com/solana that referenced this pull request Nov 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community Community contribution
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rpc: possible performance improvement for filters?
5 participants