feat: Add caching system and performance optimizations
- Add fast_fn module with global caches for PDA, ATA, and instruction operations - Implement memory-efficient caches using CLRU and parking_lot for thread-safe access - Optimize compute budget instruction generation with caching - Replace std::sync::Mutex with parking_lot::Mutex for better performance - Add dedicated caching for PumpFun PDAs and associated token addresses - Improve transaction building with batch signature optimization - Add new dependencies: clru, smallvec, parking_lot for cache infrastructure - Remove unused utility functions in pumpfun module - Enhance error messages for tip fee configuration validation
This commit is contained in:
@@ -32,14 +32,14 @@ pub async fn parallel_execute_with_tips(
|
||||
&& (swqos_clients.len() > priority_fee.buy_tip_fees.len()
|
||||
|| priority_fee.buy_tip_fees.is_empty())
|
||||
{
|
||||
return Err(anyhow!("Number of tip clients exceeds the configured buy tip fees"));
|
||||
return Err(anyhow!("Number of tip clients exceeds the configured buy tip fees. Please configure buy_tip_fees to match swqos_clients"));
|
||||
}
|
||||
if !is_buy
|
||||
&& !with_tip
|
||||
&& (swqos_clients.len() > priority_fee.sell_tip_fees.len()
|
||||
|| priority_fee.sell_tip_fees.is_empty())
|
||||
{
|
||||
return Err(anyhow!("Number of tip clients exceeds the configured sell tip fees"));
|
||||
return Err(anyhow!("Number of tip clients exceeds the configured sell tip fees. Please configure sell_tip_fees to match swqos_clients"));
|
||||
}
|
||||
|
||||
let instructions = Arc::new(instructions);
|
||||
@@ -82,7 +82,11 @@ pub async fn parallel_execute_with_tips(
|
||||
)
|
||||
.await?;
|
||||
|
||||
println!("Building transaction instructions: {:?} {:?}", swqos_type, start.elapsed());
|
||||
println!(
|
||||
"[{:?}] - Building transaction instructions: {:?}",
|
||||
swqos_type,
|
||||
start.elapsed()
|
||||
);
|
||||
|
||||
start = Instant::now();
|
||||
|
||||
@@ -93,7 +97,11 @@ pub async fn parallel_execute_with_tips(
|
||||
)
|
||||
.await?;
|
||||
|
||||
println!("Submitting transaction instructions: {:?} {:?}", swqos_type, start.elapsed());
|
||||
println!(
|
||||
"[{:?}] - Submitting transaction instructions: {:?}",
|
||||
swqos_type,
|
||||
start.elapsed()
|
||||
);
|
||||
|
||||
Ok::<(), anyhow::Error>(())
|
||||
});
|
||||
|
||||
@@ -50,6 +50,7 @@ pub struct SellParams {
|
||||
#[derive(Clone)]
|
||||
pub struct PumpFunParams {
|
||||
pub bonding_curve: Arc<BondingCurveAccount>,
|
||||
pub associated_bonding_curve: Pubkey,
|
||||
pub creator_vault: Pubkey,
|
||||
/// Whether to close token account when selling, only effective during sell operations
|
||||
pub close_token_account_when_sell: Option<bool>,
|
||||
@@ -59,6 +60,7 @@ impl PumpFunParams {
|
||||
pub fn immediate_sell(creator_vault: Pubkey, close_token_account_when_sell: bool) -> Self {
|
||||
Self {
|
||||
bonding_curve: Arc::new(BondingCurveAccount { ..Default::default() }),
|
||||
associated_bonding_curve: Pubkey::default(),
|
||||
creator_vault: creator_vault,
|
||||
close_token_account_when_sell: Some(close_token_account_when_sell),
|
||||
}
|
||||
@@ -76,6 +78,7 @@ impl PumpFunParams {
|
||||
);
|
||||
Self {
|
||||
bonding_curve: Arc::new(bonding_curve),
|
||||
associated_bonding_curve: event.associated_bonding_curve,
|
||||
creator_vault: event.creator_vault,
|
||||
close_token_account_when_sell: close_token_account_when_sell,
|
||||
}
|
||||
@@ -88,6 +91,7 @@ impl PumpFunParams {
|
||||
let bonding_curve = BondingCurveAccount::from_trade(event);
|
||||
Self {
|
||||
bonding_curve: Arc::new(bonding_curve),
|
||||
associated_bonding_curve: event.associated_bonding_curve,
|
||||
creator_vault: event.creator_vault,
|
||||
close_token_account_when_sell: close_token_account_when_sell,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user