Skip to content

Commit

Permalink
Refactor connection cache to support generic msgs (solana-labs#29774)
Browse files Browse the repository at this point in the history
tpu-client/tpu_connection_cache is refactored out the module and moved to connection-cache/connection_cache and the logic in client/connection_cache is consolidated to connection-cache/connection_cache as well. client/connection_cache only has a thin wrapper which forward calls to connection-cache/connection_cache and deal with constructions of quic/udp connection cache for clients using them both.2.

The TpuConnection is refactored to ClientConnection to make it generic and functions renamed to be proper for other workflows. eg. tpu_addr -> server_addr, send_transaction --> send_data and etc...

The enum dispatch is removed so that we can make the bulk of code of quic and udp agnostic of each other. The client is possible to load quic or udp only into its runtime.

The generic type parameter in the tpu-client/tpu_connection_cache is removed in order to create both quic and udp connection cache and use the object to send transactions with multiple branching when sending data. The generic type parameters and associated types are dropped in other types in order to make the trait "object safe" for this purpose.

I have annotated the code explaining the reasoning and the refactoring source -> destination.

There is no functional changes

bench-tps has been performed for rpc-client, thin-client and tpu-client. And it is found the performance number largely match the ones before the refactoring.
  • Loading branch information
lijunwangs authored Feb 2, 2023
1 parent 1cab61d commit ada6136
Show file tree
Hide file tree
Showing 54 changed files with 911 additions and 1,485 deletions.
27 changes: 27 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ members = [
"cli-output",
"client",
"client-test",
"connection-cache",
"core",
"dos",
"download-utils",
Expand Down
2 changes: 1 addition & 1 deletion banking-bench/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use {
transaction::Transaction,
},
solana_streamer::socket::SocketAddrSpace,
solana_tpu_client::tpu_connection_cache::DEFAULT_TPU_CONNECTION_POOL_SIZE,
solana_tpu_client::tpu_client::DEFAULT_TPU_CONNECTION_POOL_SIZE,
std::{
sync::{atomic::Ordering, Arc, RwLock},
thread::sleep,
Expand Down
4 changes: 1 addition & 3 deletions bench-tps/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ use {
pubkey::Pubkey,
signature::{read_keypair_file, Keypair},
},
solana_tpu_client::tpu_connection_cache::{
DEFAULT_TPU_CONNECTION_POOL_SIZE, DEFAULT_TPU_USE_QUIC,
},
solana_tpu_client::tpu_client::{DEFAULT_TPU_CONNECTION_POOL_SIZE, DEFAULT_TPU_USE_QUIC},
std::{
net::{Ipv4Addr, SocketAddr},
process::exit,
Expand Down
2 changes: 1 addition & 1 deletion cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use {
stake::{instruction::LockupArgs, state::Lockup},
transaction::{TransactionError, VersionedTransaction},
},
solana_tpu_client::tpu_connection_cache::DEFAULT_TPU_ENABLE_UDP,
solana_tpu_client::tpu_client::DEFAULT_TPU_ENABLE_UDP,
solana_vote_program::vote_state::VoteAuthorize,
std::{collections::HashMap, error, io::stdout, str::FromStr, sync::Arc, time::Duration},
thiserror::Error,
Expand Down
2 changes: 1 addition & 1 deletion cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use {
},
solana_remote_wallet::remote_wallet::RemoteWalletManager,
solana_rpc_client_api::config::RpcSendTransactionConfig,
solana_tpu_client::tpu_connection_cache::DEFAULT_TPU_ENABLE_UDP,
solana_tpu_client::tpu_client::DEFAULT_TPU_ENABLE_UDP,
std::{collections::HashMap, error, path::PathBuf, sync::Arc, time::Duration},
};

Expand Down
2 changes: 2 additions & 0 deletions client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ log = "0.4.17"
quinn = "0.9.3"
rand = "0.7.0"
rayon = "1.5.3"

solana-connection-cache = { path = "../connection-cache", version = "=1.16.0" }
solana-measure = { path = "../measure", version = "=1.16.0" }
solana-metrics = { path = "../metrics", version = "=1.16.0" }
solana-net-utils = { path = "../net-utils", version = "=1.16.0" }
Expand Down
Loading

0 comments on commit ada6136

Please sign in to comment.