Skip to content

Commit

Permalink
Move BankingPacket{Batch,Receiver} to solana-perf
Browse files Browse the repository at this point in the history
  • Loading branch information
ryoqun committed Dec 15, 2024
1 parent fec6c6c commit f78ec54
Show file tree
Hide file tree
Showing 14 changed files with 44 additions and 36 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions banking-bench/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ use {
solana_client::connection_cache::ConnectionCache,
solana_core::{
banking_stage::BankingStage,
banking_trace::{
BankingPacketBatch, BankingTracer, Channels, BANKING_TRACE_DIR_DEFAULT_BYTE_LIMIT,
},
banking_trace::{BankingTracer, Channels, BANKING_TRACE_DIR_DEFAULT_BYTE_LIMIT},
validator::BlockProductionMethod,
},
solana_gossip::cluster_info::{ClusterInfo, Node},
Expand All @@ -22,7 +20,7 @@ use {
leader_schedule_cache::LeaderScheduleCache,
},
solana_measure::measure::Measure,
solana_perf::packet::{to_packet_batches, PacketBatch},
solana_perf::packet::{to_packet_batches, BankingPacketBatch, PacketBatch},
solana_poh::poh_recorder::{create_test_recorder, PohRecorder, WorkingBankEntry},
solana_runtime::{
bank::Bank, bank_forks::BankForks, prioritization_fee_cache::PrioritizationFeeCache,
Expand Down
3 changes: 2 additions & 1 deletion core/benches/banking_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

use {
solana_core::{banking_trace::Channels, validator::BlockProductionMethod},
solana_perf::packet::BankingPacketBatch,
solana_vote_program::{vote_state::TowerSync, vote_transaction::new_tower_sync_transaction},
};

Expand All @@ -24,7 +25,7 @@ use {
unprocessed_transaction_storage::{ThreadType, UnprocessedTransactionStorage},
BankingStage, BankingStageStats,
},
banking_trace::{BankingPacketBatch, BankingTracer},
banking_trace::BankingTracer,
},
solana_entry::entry::{next_hash, Entry},
solana_gossip::cluster_info::{ClusterInfo, Node},
Expand Down
5 changes: 3 additions & 2 deletions core/benches/banking_trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ use {
for_test::{
drop_and_clean_temp_dir_unless_suppressed, sample_packet_batch, terminate_tracer,
},
receiving_loop_with_minimized_sender_overhead, BankingPacketBatch, BankingTracer, Channels,
TraceError, TracerThreadResult, BANKING_TRACE_DIR_DEFAULT_BYTE_LIMIT,
receiving_loop_with_minimized_sender_overhead, BankingTracer, Channels, TraceError,
TracerThreadResult, BANKING_TRACE_DIR_DEFAULT_BYTE_LIMIT,
},
solana_perf::packet::BankingPacketBatch,
std::{
path::PathBuf,
sync::{atomic::AtomicBool, Arc},
Expand Down
6 changes: 3 additions & 3 deletions core/src/banking_simulation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ use {
crate::{
banking_stage::{BankingStage, LikeClusterInfo},
banking_trace::{
BankingPacketBatch, BankingTracer, ChannelLabel, Channels, TimedTracedEvent,
TracedEvent, TracedSender, TracerThread, BANKING_TRACE_DIR_DEFAULT_BYTE_LIMIT,
BASENAME,
BankingTracer, ChannelLabel, Channels, TimedTracedEvent, TracedEvent, TracedSender,
TracerThread, BANKING_TRACE_DIR_DEFAULT_BYTE_LIMIT, BASENAME,
},
validator::BlockProductionMethod,
},
Expand All @@ -23,6 +22,7 @@ use {
leader_schedule_cache::LeaderScheduleCache,
},
solana_net_utils::bind_to_localhost,
solana_perf::packet::BankingPacketBatch,
solana_poh::{
poh_recorder::{PohRecorder, GRACE_TICKS_FACTOR, MAX_GRACE_SLOTS},
poh_service::{PohService, DEFAULT_HASHES_PER_BATCH, DEFAULT_PINNED_CPU_CORE},
Expand Down
10 changes: 6 additions & 4 deletions core/src/banking_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ use {
scheduler_controller::SchedulerController, scheduler_error::SchedulerError,
},
},
banking_trace::BankingPacketReceiver,
validator::BlockProductionMethod,
},
crossbeam_channel::{unbounded, Receiver, RecvTimeoutError, Sender},
Expand All @@ -33,7 +32,10 @@ use {
solana_gossip::{cluster_info::ClusterInfo, contact_info::ContactInfo},
solana_ledger::blockstore_processor::TransactionStatusSender,
solana_measure::measure_us,
solana_perf::{data_budget::DataBudget, packet::PACKETS_PER_BATCH},
solana_perf::{
data_budget::DataBudget,
packet::{BankingPacketReceiver, PACKETS_PER_BATCH},
},
solana_poh::poh_recorder::{PohRecorder, TransactionRecorder},
solana_runtime::{
bank_forks::BankForks, prioritization_fee_cache::PrioritizationFeeCache,
Expand Down Expand Up @@ -807,7 +809,7 @@ impl BankingStage {
mod tests {
use {
super::*,
crate::banking_trace::{BankingPacketBatch, BankingTracer, Channels},
crate::banking_trace::{BankingTracer, Channels},
crossbeam_channel::{unbounded, Receiver},
itertools::Itertools,
solana_entry::entry::{self, Entry, EntrySlice},
Expand All @@ -820,7 +822,7 @@ mod tests {
get_tmp_ledger_path_auto_delete,
leader_schedule_cache::LeaderScheduleCache,
},
solana_perf::packet::{to_packet_batches, PacketBatch},
solana_perf::packet::{to_packet_batches, BankingPacketBatch, PacketBatch},
solana_poh::{
poh_recorder::{
create_test_recorder, PohRecorderError, Record, RecordTransactionsSummary,
Expand Down
3 changes: 1 addition & 2 deletions core/src/banking_stage/packet_deserializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ use {
immutable_deserialized_packet::{DeserializedPacketError, ImmutableDeserializedPacket},
packet_filter::PacketFilterFailure,
},
crate::banking_trace::{BankingPacketBatch, BankingPacketReceiver},
crossbeam_channel::RecvTimeoutError,
solana_perf::packet::PacketBatch,
solana_perf::packet::{BankingPacketBatch, BankingPacketReceiver, PacketBatch},
solana_sdk::saturating_add_assign,
std::time::{Duration, Instant},
};
Expand Down
2 changes: 1 addition & 1 deletion core/src/banking_stage/packet_receiver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ use {
unprocessed_transaction_storage::UnprocessedTransactionStorage,
BankingStageStats,
},
crate::banking_trace::BankingPacketReceiver,
crossbeam_channel::RecvTimeoutError,
solana_measure::{measure::Measure, measure_us},
solana_perf::packet::BankingPacketReceiver,
solana_sdk::{saturating_add_assign, timing::timestamp},
std::{sync::atomic::Ordering, time::Duration},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,18 +435,15 @@ impl<C: LikeClusterInfo, R: ReceiveAndBuffer> SchedulerController<C, R> {
mod tests {
use {
super::*,
crate::{
banking_stage::{
consumer::TARGET_NUM_TRANSACTIONS_PER_BATCH,
packet_deserializer::PacketDeserializer,
scheduler_messages::{ConsumeWork, FinishedConsumeWork, TransactionBatchId},
tests::create_slow_genesis_config,
transaction_scheduler::{
prio_graph_scheduler::PrioGraphSchedulerConfig,
receive_and_buffer::SanitizedTransactionReceiveAndBuffer,
},
crate::banking_stage::{
consumer::TARGET_NUM_TRANSACTIONS_PER_BATCH,
packet_deserializer::PacketDeserializer,
scheduler_messages::{ConsumeWork, FinishedConsumeWork, TransactionBatchId},
tests::create_slow_genesis_config,
transaction_scheduler::{
prio_graph_scheduler::PrioGraphSchedulerConfig,
receive_and_buffer::SanitizedTransactionReceiveAndBuffer,
},
banking_trace::BankingPacketBatch,
},
crossbeam_channel::{unbounded, Receiver, Sender},
itertools::Itertools,
Expand All @@ -455,7 +452,7 @@ mod tests {
blockstore::Blockstore, genesis_utils::GenesisConfigInfo,
get_tmp_ledger_path_auto_delete, leader_schedule_cache::LeaderScheduleCache,
},
solana_perf::packet::{to_packet_batches, PacketBatch, NUM_PACKETS},
solana_perf::packet::{to_packet_batches, BankingPacketBatch, PacketBatch, NUM_PACKETS},
solana_poh::poh_recorder::{PohRecorder, Record, WorkingBankEntry},
solana_runtime::bank::Bank,
solana_runtime_transaction::runtime_transaction::RuntimeTransaction,
Expand Down
4 changes: 1 addition & 3 deletions core/src/banking_trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use {
chrono::{DateTime, Local},
crossbeam_channel::{unbounded, Receiver, SendError, Sender, TryRecvError},
rolling_file::{RollingCondition, RollingConditionBasic, RollingFileAppender},
solana_perf::packet::PacketBatch,
solana_perf::packet::{BankingPacketBatch, BankingPacketReceiver},
solana_sdk::{hash::Hash, slot_history::Slot},
std::{
fs::{create_dir_all, remove_dir_all},
Expand All @@ -19,9 +19,7 @@ use {
thiserror::Error,
};

pub type BankingPacketBatch = Arc<Vec<PacketBatch>>;
pub type BankingPacketSender = TracedSender;
pub type BankingPacketReceiver = Receiver<BankingPacketBatch>;
pub type TracerThreadResult = Result<(), TraceError>;
pub type TracerThread = Option<JoinHandle<TracerThreadResult>>;
pub type DirByteLimit = u64;
Expand Down
4 changes: 2 additions & 2 deletions core/src/cluster_info_vote_listener.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use {
crate::{
banking_trace::{BankingPacketBatch, BankingPacketSender},
banking_trace::BankingPacketSender,
consensus::vote_stake_tracker::VoteStakeTracker,
optimistic_confirmation_verifier::OptimisticConfirmationVerifier,
replay_stage::DUPLICATE_THRESHOLD,
Expand All @@ -16,7 +16,7 @@ use {
solana_ledger::blockstore::Blockstore,
solana_measure::measure::Measure,
solana_metrics::inc_new_counter_debug,
solana_perf::packet::{self, PacketBatch},
solana_perf::packet::{self, BankingPacketBatch, PacketBatch},
solana_rpc::{
optimistically_confirmed_bank_tracker::{BankNotification, BankNotificationSender},
rpc_subscriptions::RpcSubscriptions,
Expand Down
9 changes: 7 additions & 2 deletions core/src/sigverify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,15 @@ pub use solana_perf::sigverify::{
};
use {
crate::{
banking_trace::{BankingPacketBatch, BankingPacketSender},
banking_trace::BankingPacketSender,
sigverify_stage::{SigVerifier, SigVerifyServiceError},
},
solana_perf::{cuda_runtime::PinnedVec, packet::PacketBatch, recycler::Recycler, sigverify},
solana_perf::{
cuda_runtime::PinnedVec,
packet::{BankingPacketBatch, PacketBatch},
recycler::Recycler,
sigverify,
},
};

pub struct TransactionSigVerifier {
Expand Down
1 change: 1 addition & 0 deletions perf/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ edition = { workspace = true }
ahash = { workspace = true }
bincode = { workspace = true }
bv = { workspace = true, features = ["serde"] }
crossbeam-channel = { workspace = true }
curve25519-dalek = { workspace = true }
dlopen2 = { workspace = true }
fnv = { workspace = true }
Expand Down
5 changes: 5 additions & 0 deletions perf/src/packet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ pub use solana_packet::{self, Meta, Packet, PacketFlags, PACKET_DATA_SIZE};
use {
crate::{cuda_runtime::PinnedVec, recycler::Recycler},
bincode::config::Options,
crossbeam_channel::Receiver,
rayon::prelude::{IntoParallelIterator, IntoParallelRefIterator, IntoParallelRefMutIterator},
serde::{de::DeserializeOwned, Deserialize, Serialize},
std::{
io::Read,
net::SocketAddr,
ops::{Index, IndexMut},
slice::{Iter, IterMut, SliceIndex},
sync::Arc,
},
};

Expand Down Expand Up @@ -226,6 +228,9 @@ pub fn to_packet_batches<T: Serialize>(items: &[T], chunk_size: usize) -> Vec<Pa
.collect()
}

pub type BankingPacketBatch = Arc<Vec<PacketBatch>>;
pub type BankingPacketReceiver = Receiver<BankingPacketBatch>;

#[cfg(test)]
fn to_packet_batches_for_tests<T: Serialize>(items: &[T]) -> Vec<PacketBatch> {
to_packet_batches(items, NUM_PACKETS)
Expand Down

0 comments on commit f78ec54

Please sign in to comment.