-
Notifications
You must be signed in to change notification settings - Fork 16
TCP CRR workload #1906
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
usamasaqib
wants to merge
13
commits into
usama.saqib/rr-refactor
Choose a base branch
from
usamasaqib/tcp-crr
base: usama.saqib/rr-refactor
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
TCP CRR workload #1906
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
9443fca
introduce tcp crr
usamasaqib a954228
fix flow management so that FlowMap is a ring buffer and reuses slots
usamasaqib 4ca89fa
fix off-by-one
usamasaqib ac7aa5c
use warn to report errors
usamasaqib cacb587
increment connections closed when connection closes cleanly
usamasaqib e883997
guard against token mismatch is FlowMap
usamasaqib 69e43c0
for tcp_crr, when a very large number of flows are created connect ca…
usamasaqib 301c265
remove comment about increasing local port range with sysctl
usamasaqib 21fc427
address clippy issues
usamasaqib 935256d
remove non ascii chars
usamasaqib 1bc4a4a
in order to Use dedicated ports on generator side for each flow.
usamasaqib 5d0b2fd
format
usamasaqib d4e7bf4
remove manual port management for flows
usamasaqib File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,144 @@ | ||
| //! TCP connect/request/response (`tcp_crr`) blackhole - the server side. | ||
| //! Based on <https://github.com/google/neper> | ||
| //! | ||
| //! Listens for incoming connections and, for each flow, reads a fixed-size | ||
| //! request then writes a fixed-size response. The CRR client closes the | ||
| //! connection after each response; the server side is identical to `tcp_rr` | ||
| //! and delegates to the same shared machinery. | ||
| //! | ||
| //! The event-loop machinery lives in [`crate::neper::rr`]; this module is a | ||
| //! thin wrapper that supplies configuration. | ||
| //! | ||
| //! ## Metrics | ||
| //! | ||
| //! `connections_accepted`: Incoming connections accepted | ||
| //! `requests_received`: Completed request reads | ||
| //! `responses_sent`: Completed response writes | ||
| //! `bytes_received`: Request bytes read | ||
| //! `bytes_written`: Response bytes sent | ||
| //! `connections_closed`: Flow removals (client close + I/O errors) | ||
|
|
||
| use std::net::{IpAddr, SocketAddr}; | ||
| use std::num::{NonZeroU16, NonZeroUsize}; | ||
|
|
||
| use serde::{Deserialize, Serialize}; | ||
|
|
||
| use super::General; | ||
| use crate::neper::rr::{self, Mode, ServerParams}; | ||
|
|
||
| fn default_nonzero_u16() -> NonZeroU16 { | ||
| NonZeroU16::new(1).expect("1 is nonzero") | ||
| } | ||
|
|
||
| fn default_nonzero_usize() -> NonZeroUsize { | ||
| NonZeroUsize::new(1).expect("1 is nonzero") | ||
| } | ||
|
|
||
| fn default_control_port() -> u16 { | ||
| 12866 | ||
| } | ||
|
|
||
| fn default_data_port() -> u16 { | ||
| 12867 | ||
| } | ||
|
|
||
| fn default_backlog() -> i32 { | ||
| 1024 | ||
| } | ||
|
|
||
| const fn default_true() -> bool { | ||
| true | ||
| } | ||
|
|
||
| #[derive(Debug, Deserialize, Serialize, Clone, Copy, PartialEq, Eq)] | ||
| #[serde(deny_unknown_fields)] | ||
| /// Configuration for the `tcp_crr` blackhole. | ||
| pub struct Config { | ||
| /// IP address to bind on. | ||
| pub addr: IpAddr, | ||
| /// Data port for flow connections. Default 12867. | ||
| #[serde(default = "default_data_port")] | ||
| pub data_port: u16, | ||
| /// Control port for startup synchronization with the generator. Default 12866. | ||
| #[serde(default = "default_control_port")] | ||
| pub control_port: u16, | ||
| /// Number of OS server threads. Default 1. When > 1, uses `SO_REUSEPORT` | ||
| /// with an eBPF program for load balancing. | ||
| #[serde(default = "default_nonzero_u16")] | ||
| pub threads: NonZeroU16, | ||
| /// Total number of TCP flows the generator should open (neper `-F`). | ||
| /// Default 1. Sent to the generator over the control connection at | ||
| /// startup; the generator does not configure this independently. | ||
| #[serde(default = "default_nonzero_u16")] | ||
| pub flows: NonZeroU16, | ||
| /// Bytes to read per request. Default 1. | ||
| #[serde(default = "default_nonzero_usize")] | ||
| pub request_size: NonZeroUsize, | ||
| /// Bytes to send per response. Default 1. | ||
| #[serde(default = "default_nonzero_usize")] | ||
| pub response_size: NonZeroUsize, | ||
| /// Whether to set `TCP_NODELAY` on accepted connections. Default true. | ||
| #[serde(default = "default_true")] | ||
| pub no_delay: bool, | ||
| /// Listener backlog (pending-connection queue length) passed to `listen(2)`. | ||
| /// Default 1024. CRR workloads benefit from a larger backlog to absorb | ||
| /// connect bursts. | ||
| #[serde(default = "default_backlog")] | ||
| pub backlog: i32, | ||
| } | ||
|
|
||
| #[derive(thiserror::Error, Debug)] | ||
| /// Errors produced by [`TcpCrr`]. | ||
| pub enum Error { | ||
| /// Shared neper-style request/response error. | ||
| #[error(transparent)] | ||
| Rr(#[from] rr::Error), | ||
| } | ||
|
|
||
| #[derive(Debug)] | ||
| /// The `tcp_crr` blackhole (server side). | ||
| pub struct TcpCrr { | ||
| config: Config, | ||
| metric_labels: Vec<(String, String)>, | ||
| shutdown: lading_signal::Watcher, | ||
| } | ||
|
|
||
| impl TcpCrr { | ||
| /// Create a new [`TcpCrr`] blackhole instance. | ||
| #[must_use] | ||
| pub fn new(general: General, config: &Config, shutdown: lading_signal::Watcher) -> Self { | ||
| let mut metric_labels = vec![ | ||
| ("component".to_string(), "blackhole".to_string()), | ||
| ("component_name".to_string(), "tcp_crr".to_string()), | ||
| ]; | ||
| if let Some(id) = general.id { | ||
| metric_labels.push(("id".to_string(), id)); | ||
| } | ||
| Self { | ||
| config: *config, | ||
| metric_labels, | ||
| shutdown, | ||
| } | ||
| } | ||
|
|
||
| /// Run the blackhole to completion or until a shutdown signal is received. | ||
| /// | ||
| /// # Errors | ||
| /// | ||
| /// Returns an error if binding fails or a worker thread panics. | ||
| pub async fn run(self) -> Result<(), Error> { | ||
| let params = ServerParams { | ||
| data_addr: SocketAddr::new(self.config.addr, self.config.data_port), | ||
| control_addr: SocketAddr::new(self.config.addr, self.config.control_port), | ||
| threads: self.config.threads.get(), | ||
| flows: self.config.flows.get(), | ||
| request_size: self.config.request_size.get(), | ||
| response_size: self.config.response_size.get(), | ||
| no_delay: self.config.no_delay, | ||
| backlog: self.config.backlog, | ||
| mode: Mode::Crr, | ||
| }; | ||
| rr::run_server(params, self.metric_labels, self.shutdown, "tcp_crr").await?; | ||
| Ok(()) | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For sustained
tcp_crrruns this delegates the blackhole to the RR server path, but each CRR transaction creates a new server-side connection whilerr::server_thread_mainassigns a fresh monotonically increasing token on every accept andFlowMapexplicitly never reuses removed slots (lading/src/neper/rr.rs:753-761,lading/src/neper/flow.rs:31-50). As a result the server's backingVec<Option<Flow<_>>>grows by one slot per request/response cycle even after connections close, so a high-rate CRR experiment will steadily consume memory until lading itself becomes the bottleneck or OOMs.Useful? React with 👍 / 👎.