perf: Major event processing system refactor for improved performance

This commit is contained in:
ysq
2025-08-29 14:59:16 +08:00
parent 218abd3aa4
commit b535bdf052
23 changed files with 1557 additions and 894 deletions
+13 -13
View File
@@ -61,7 +61,7 @@ async fn test_grpc() -> Result<(), Box<dyn std::error::Error>> {
println!("Subscribing to Yellowstone gRPC events...");
// Create low-latency configuration
let mut config = ClientConfig::low_latency();
let mut config: ClientConfig = ClientConfig::low_latency();
// Enable performance monitoring, has performance overhead, disabled by default
config.enable_metrics = true;
let grpc = YellowstoneGrpc::new_with_config(
@@ -86,17 +86,13 @@ async fn test_grpc() -> Result<(), Box<dyn std::error::Error>> {
println!("Protocols to monitor: {:?}", protocols);
const SYSTEM_PROGRAM_ID: solana_sdk::pubkey::Pubkey =
solana_sdk::pubkey!("11111111111111111111111111111111");
// Filter accounts
let account_include = vec![
SYSTEM_PROGRAM_ID.to_string(),
PUMPFUN_PROGRAM_ID.to_string(), // Listen to pumpfun program ID
PUMPSWAP_PROGRAM_ID.to_string(), // Listen to pumpswap program ID
BONK_PROGRAM_ID.to_string(), // Listen to bonk program ID
RAYDIUM_CPMM_PROGRAM_ID.to_string(), // Listen to raydium_cpmm program ID
RAYDIUM_CLMM_PROGRAM_ID.to_string(), // Listen to raydium_clmm program ID
PUMPFUN_PROGRAM_ID.to_string(), // Listen to pumpfun program ID
PUMPSWAP_PROGRAM_ID.to_string(), // Listen to pumpswap program ID
BONK_PROGRAM_ID.to_string(), // Listen to bonk program ID
RAYDIUM_CPMM_PROGRAM_ID.to_string(), // Listen to raydium_cpmm program ID
RAYDIUM_CLMM_PROGRAM_ID.to_string(), // Listen to raydium_clmm program ID
RAYDIUM_AMM_V4_PROGRAM_ID.to_string(), // Listen to raydium_amm_v4 program ID
];
let account_exclude = vec![];
@@ -116,7 +112,7 @@ async fn test_grpc() -> Result<(), Box<dyn std::error::Error>> {
// No event filtering, includes all events
let event_type_filter = None;
// Only include PumpSwapBuy events and PumpSwapSell events
// let event_type_filter = EventTypeFilter { include: vec![EventType::PumpSwapBuy, EventType::PumpSwapSell] };
// let event_type_filter = Some(EventTypeFilter { include: vec![EventType::PumpFunBuy] });
println!("Starting to listen for events, press Ctrl+C to stop...");
println!("Monitoring programs: {:?}", account_include);
@@ -155,7 +151,7 @@ async fn test_shreds() -> Result<(), Box<dyn std::error::Error>> {
// Enable performance monitoring, has performance overhead, disabled by default
config.enable_metrics = true;
let shred_stream =
ShredStreamGrpc::new_with_config("http://64.130.37.195:10800".to_string(), config).await?;
ShredStreamGrpc::new_with_config("http://127.0.0.1:10800".to_string(), config).await?;
let callback = create_event_callback();
let protocols = vec![
@@ -192,7 +188,11 @@ async fn test_shreds() -> Result<(), Box<dyn std::error::Error>> {
fn create_event_callback() -> impl Fn(Box<dyn UnifiedEvent>) {
|event: Box<dyn UnifiedEvent>| {
println!("🎉 Event received! Type: {:?}, ID: {}", event.event_type(), event.id());
println!(
"🎉 Event received! Type: {:?}, transaction_index: {:?}",
event.event_type(),
event.transaction_index()
);
match_event!(event, {
// -------------------------- block meta -----------------------
BlockMetaEvent => |e: BlockMetaEvent| {