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

NDEV-3112. Optimize getting of deactivated features #566

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

ancientmage
Copy link

No description provided.

Copy link

@s-medvedev s-medvedev left a comment

Choose a reason for hiding this comment

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

It's incorrect to use CallDbClient::get_multiple_accounts to get a list of accounts with features and then cache them because CallDbClient works with the specific slot (and this time slot will be different for each CallDbClient instance).
Fortunatelly, features can be only enabled, and never disabled. So if we have activated features with a slot for the current time, we always can build a list of features activated at any previous slot. For this, it's enough to create a list of features whose activation time is None or more than the specified slot.

@ancientmage ancientmage force-pushed the NDEV-3112-optimize-getting-deactivated-features branch from b1e279f to 6062b31 Compare December 10, 2024 16:00
@ancientmage ancientmage force-pushed the NDEV-3112-optimize-getting-deactivated-features branch from 23ef0b3 to e8149cc Compare December 16, 2024 12:57
@neonlabstech
Copy link

Dapps report

🔗Cost report

@neonlabstech
Copy link

Solana Requests Statistics
count min_time max_time average_time median_time
getSlot 145364 0 0.123 0.000394905 0
getBlocks 64833 0 0.029 0.000386439 0
getAccountInfo 64813 0 0.269 0.000527055 0
getBlock 32649 0 0.031 0.00102576 0.001
getMultipleAccounts 21618 0 0.166 0.000921871 0.001
getLatestBlockhash 17643 0 0.133 0.000880292 0
getTransaction 10223 0 0.434 0.0096591 0.002
getBlockTime 6268 0 0.177 0.000334078 0
sendTransaction 5173 0 0.377 0.00652252 0.003
getBalance 1794 0 0.131 0.000701784 0
getSignatureStatuses 1102 0 0.139 0.000612523 0
getVersion 588 0 0.065 0.00106633 0
simulateTransaction 545 0 0.006 0.00140183 0.001
isBlockhashValid 533 0 0.005 0.000253283 0
getSignaturesForAddress 58 0 0.003 0.00118966 0.001
requestAirdrop 32 0 0.001 0.00075 0.001
getTokenAccountBalance 10 0 0.001 0.0004 0
getHealth 3 0 0 0 0
getFirstAvailableBlock 2 0 0.001 0.0005 0.0005
getMinimumBalanceForRentExemption 1 0 0 0 0
getClusterNodes 1 0 0 0 0

@@ -88,6 +89,6 @@ impl Rpc for CallDbClient {
}

async fn get_deactivated_solana_features(&self) -> ClientResult<Vec<Pubkey>> {
Ok(vec![]) // TODO
get_deactivated_features(self, Some(self.slot)).await

Choose a reason for hiding this comment

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

You have to use CloneRpcClient to get_deactivated_features or the logic of it will be broken.

}
}

static DEACTIVATED_FEATURES: Lazy<Arc<Mutex<DeactivatedFeaturesCache>>> =

Choose a reason for hiding this comment

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

Why don't you use RwLock instead of Mutex?

Copy link
Author

Choose a reason for hiding this comment

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

Because we cannot call await of async function under lock of RwLock. In our case we need to call async Rpc::get_multiple_accounts

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.

3 participants