mirror of
https://github.com/0xfnzero/solana-streamer.git
synced 2026-08-20 12:28:08 +00:00
perf: implement SIMD-accelerated event processing and optimize streaming performance
- Add SIMD utilities for fast byte array comparison and discriminator matching - Optimize event processor with batch processing and memory pool - Refactor global state management with concurrent data structures - Remove deprecated batch processing module - Enhance metrics collection with reduced overhead - Improve parser efficiency across all protocol implementations - Add performance benchmarking dependencies (criterion, wide) - Update documentation and examples for new architecture Performance improvements: - SIMD-accelerated byte operations for instruction parsing - Concurrent HashMap (DashMap) for better multi-threading - Optimized memory allocation patterns - Reduced lock contention in event processing pipeline Breaking changes: Removed batch.rs module, updated parser interfaces
This commit is contained in:
@@ -14,7 +14,7 @@ use crate::common::AnyResult;
|
||||
use crate::streaming::common::StreamClientConfig as ClientConfig;
|
||||
use crate::streaming::event_parser::common::filter::EventTypeFilter;
|
||||
|
||||
/// 订阅管理器
|
||||
/// Subscription manager
|
||||
#[derive(Clone)]
|
||||
pub struct SubscriptionManager {
|
||||
endpoint: String,
|
||||
@@ -23,12 +23,12 @@ pub struct SubscriptionManager {
|
||||
}
|
||||
|
||||
impl SubscriptionManager {
|
||||
/// 创建新的订阅管理器
|
||||
/// Create a new subscription manager
|
||||
pub fn new(endpoint: String, x_token: Option<String>, config: ClientConfig) -> Self {
|
||||
Self { endpoint, x_token, config }
|
||||
}
|
||||
|
||||
/// 创建 gRPC 连接
|
||||
/// Create gRPC connection
|
||||
pub async fn connect(&self) -> AnyResult<GeyserGrpcClient<impl Interceptor>> {
|
||||
let builder = GeyserGrpcClient::build_from_shared(self.endpoint.clone())?
|
||||
.x_token(self.x_token.clone())?
|
||||
@@ -39,20 +39,20 @@ impl SubscriptionManager {
|
||||
Ok(builder.connect().await?)
|
||||
}
|
||||
|
||||
/// 创建订阅请求并返回流
|
||||
/// Create subscription request and return stream
|
||||
pub async fn subscribe_with_request(
|
||||
&self,
|
||||
transactions: Option<TransactionsFilterMap>,
|
||||
accounts: Option<AccountsFilterMap>,
|
||||
commitment: Option<CommitmentLevel>,
|
||||
event_type_filter: Option<EventTypeFilter>,
|
||||
event_type_filter: Option<&EventTypeFilter>,
|
||||
) -> AnyResult<(
|
||||
impl Sink<SubscribeRequest, Error = mpsc::SendError>,
|
||||
impl Stream<Item = Result<SubscribeUpdate, Status>>,
|
||||
SubscribeRequest,
|
||||
)> {
|
||||
let blocks_meta = if event_type_filter.is_some()
|
||||
&& event_type_filter.as_ref().unwrap().include_block_event()
|
||||
&& event_type_filter.unwrap().include_block_event()
|
||||
{
|
||||
hashmap! { "".to_owned() => SubscribeRequestFilterBlocksMeta {} }
|
||||
} else if event_type_filter.is_none() {
|
||||
@@ -76,18 +76,18 @@ impl SubscriptionManager {
|
||||
Ok((sink, stream, subscribe_request))
|
||||
}
|
||||
|
||||
/// 创建账户订阅请求并返回流
|
||||
/// Create account subscription request and return stream
|
||||
pub fn subscribe_with_account_request(
|
||||
&self,
|
||||
account: Vec<String>,
|
||||
owner: Vec<String>,
|
||||
event_type_filter: Option<EventTypeFilter>,
|
||||
event_type_filter: Option<&EventTypeFilter>,
|
||||
) -> Option<AccountsFilterMap> {
|
||||
if account.len() == 0 && owner.len() == 0 {
|
||||
return None;
|
||||
}
|
||||
if event_type_filter.is_some()
|
||||
&& !event_type_filter.as_ref().unwrap().include_account_event()
|
||||
&& !event_type_filter.unwrap().include_account_event()
|
||||
{
|
||||
return None;
|
||||
}
|
||||
@@ -104,16 +104,16 @@ impl SubscriptionManager {
|
||||
Some(accounts)
|
||||
}
|
||||
|
||||
/// 生成订阅请求过滤器
|
||||
/// Generate subscription request filter
|
||||
pub fn get_subscribe_request_filter(
|
||||
&self,
|
||||
account_include: Vec<String>,
|
||||
account_exclude: Vec<String>,
|
||||
account_required: Vec<String>,
|
||||
event_type_filter: Option<EventTypeFilter>,
|
||||
event_type_filter: Option<&EventTypeFilter>,
|
||||
) -> Option<TransactionsFilterMap> {
|
||||
if event_type_filter.is_some()
|
||||
&& !event_type_filter.as_ref().unwrap().include_transaction_event()
|
||||
&& !event_type_filter.unwrap().include_transaction_event()
|
||||
{
|
||||
return None;
|
||||
}
|
||||
@@ -132,7 +132,7 @@ impl SubscriptionManager {
|
||||
Some(transactions)
|
||||
}
|
||||
|
||||
/// 获取配置
|
||||
/// Get configuration
|
||||
pub fn get_config(&self) -> &ClientConfig {
|
||||
&self.config
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user