Make the threshold for predictive echo configurable
Introduce a new config knob called 'local_echo_threshold_ms' to let users configure when the local echo prediction should kick in. The default value is 100ms to retain the current behavior.
This commit is contained in:
1 parent
0c6b4e261d
commit
39086c048b
6 files changed
+36
-4
No files matched your search
@@ -1126,6 +1126,10 @@ pub fn default_write_timeout() -> Duration {
|
||||
Duration::from_secs(60)
|
||||
}
|
||||
|
||||
pub fn default_local_echo_threshold_ms() -> Option<u64> {
|
||||
Some(100)
|
||||
}
|
||||
|
||||
fn default_bypass_mouse_reporting_modifiers() -> Modifiers {
|
||||
Modifiers::SHIFT
|
||||
}
|
||||
|
||||
@@ -70,6 +70,9 @@ pub struct SshDomain {
|
||||
#[serde(default = "default_read_timeout")]
|
||||
pub timeout: Duration,
|
||||
|
||||
#[serde(default = "default_local_echo_threshold_ms")]
|
||||
pub local_echo_threshold_ms: Option<u64>,
|
||||
|
||||
/// The path to the wezterm binary on the remote host
|
||||
pub remote_wezterm_path: Option<String>,
|
||||
|
||||
|
||||
@@ -80,6 +80,9 @@ pub struct TlsDomainClient {
|
||||
#[serde(default = "default_write_timeout")]
|
||||
pub write_timeout: Duration,
|
||||
|
||||
#[serde(default = "default_local_echo_threshold_ms")]
|
||||
pub local_echo_threshold_ms: Option<u64>,
|
||||
|
||||
/// The path to the wezterm binary on the remote host
|
||||
pub remote_wezterm_path: Option<String>,
|
||||
}
|
||||
|
||||
@@ -48,6 +48,10 @@ pub struct UnixDomain {
|
||||
|
||||
#[serde(default = "default_write_timeout")]
|
||||
pub write_timeout: Duration,
|
||||
|
||||
/// Don't use default_local_echo_threshold_ms() here to
|
||||
/// disable the predictive echo for Unix domains by default.
|
||||
pub local_echo_threshold_ms: Option<u64>,
|
||||
}
|
||||
impl_lua_conversion!(UnixDomain);
|
||||
|
||||
@@ -62,6 +66,7 @@ impl Default for UnixDomain {
|
||||
skip_permissions_check: false,
|
||||
read_timeout: default_read_timeout(),
|
||||
write_timeout: default_write_timeout(),
|
||||
local_echo_threshold_ms: None,
|
||||
proxy_command: None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ pub struct ClientInner {
|
||||
pub client: Client,
|
||||
pub local_domain_id: DomainId,
|
||||
pub remote_domain_id: DomainId,
|
||||
pub local_echo_threshold_ms: Option<u64>,
|
||||
remote_to_local_window: Mutex<HashMap<WindowId, WindowId>>,
|
||||
remote_to_local_tab: Mutex<HashMap<TabId, TabId>>,
|
||||
remote_to_local_pane: Mutex<HashMap<PaneId, PaneId>>,
|
||||
@@ -128,6 +129,14 @@ impl ClientDomainConfig {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn local_echo_threshold_ms(&self) -> Option<u64> {
|
||||
match self {
|
||||
ClientDomainConfig::Unix(unix) => unix.local_echo_threshold_ms,
|
||||
ClientDomainConfig::Tls(tls) => tls.local_echo_threshold_ms,
|
||||
ClientDomainConfig::Ssh(ssh) => ssh.local_echo_threshold_ms,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn label(&self) -> String {
|
||||
match self {
|
||||
ClientDomainConfig::Unix(unix) => format!("unix mux {}", unix.socket_path().display()),
|
||||
@@ -152,7 +161,11 @@ impl ClientDomainConfig {
|
||||
}
|
||||
|
||||
impl ClientInner {
|
||||
pub fn new(local_domain_id: DomainId, client: Client) -> Self {
|
||||
pub fn new(
|
||||
local_domain_id: DomainId,
|
||||
client: Client,
|
||||
local_echo_threshold_ms: Option<u64>,
|
||||
) -> Self {
|
||||
// Assumption: that the domain id on the other end is
|
||||
// always the first created default domain. In the future
|
||||
// we'll add a way to discover/enumerate domains to populate
|
||||
@@ -162,6 +175,7 @@ impl ClientInner {
|
||||
client,
|
||||
local_domain_id,
|
||||
remote_domain_id,
|
||||
local_echo_threshold_ms,
|
||||
remote_to_local_window: Mutex::new(HashMap::new()),
|
||||
remote_to_local_tab: Mutex::new(HashMap::new()),
|
||||
remote_to_local_pane: Mutex::new(HashMap::new()),
|
||||
@@ -407,8 +421,9 @@ impl ClientDomain {
|
||||
let domain = domain
|
||||
.downcast_ref::<Self>()
|
||||
.ok_or_else(|| anyhow!("domain {} is not a ClientDomain", domain_id))?;
|
||||
let threshold = domain.config.local_echo_threshold_ms();
|
||||
|
||||
let inner = Arc::new(ClientInner::new(domain_id, client));
|
||||
let inner = Arc::new(ClientInner::new(domain_id, client, threshold));
|
||||
*domain.inner.borrow_mut() = Some(Arc::clone(&inner));
|
||||
|
||||
Self::process_pane_list(inner, panes)?;
|
||||
|
||||
@@ -133,9 +133,11 @@ impl RenderableInner {
|
||||
|
||||
/// Predictive echo can be noisy when the link is working well,
|
||||
/// so we only employ it when it looks like the latency is high.
|
||||
/// We pick 100ms as the threshold for this.
|
||||
fn should_predict(&self) -> bool {
|
||||
!self.client.is_local() && self.last_input_rtt >= 100
|
||||
self.client
|
||||
.local_echo_threshold_ms
|
||||
.map(|thresh| self.last_input_rtt >= thresh)
|
||||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
/// Compute a "prediction" and apply it to the line data that we
|
||||
|
||||
Reference in new issue
Block a user