Skip to content

quality: PR5 — perf, quality, and dead-code cleanups#14

Merged
Itsusinn merged 3 commits into
mainfrom
quality/pr5-perf-and-cleanups
Jun 5, 2026
Merged

quality: PR5 — perf, quality, and dead-code cleanups#14
Itsusinn merged 3 commits into
mainfrom
quality/pr5-perf-and-cleanups

Conversation

@Itsusinn

@Itsusinn Itsusinn commented Jun 5, 2026

Copy link
Copy Markdown
Member

Summary

Last wave of the full-project review — quality / performance / dead-code findings. Mostly small, low-risk janitorial changes; a few sit on a hot path.

Perf / correctness

  • rustls install_default runs once. TuicOutbound::new previously called it on every construction and silently swallowed the post-first Err. Now guarded by static OnceLock<()>.
  • tuic-server::acl zero-alloc Display. format_protocol returns &'static str; format_optional_parts returns a Display wrapper. Both were on the rule-pretty-print hot path.
  • wind-tuic::quinn::inbound::acceptor_loop: ApplicationClosed/LocallyClosed/TimedOut no longer logged as ERROR (they're benign connection-lifecycle events). Demoted to DEBUG.

Quality / safety

  • wind::log filter now lists every wind crate; wind_acme/wind_base/wind_dns/wind_naive were missing and silently fell through to the default INFO.
  • WIND_OVERRIVE_VERSION typo fixed. Canonical name is now WIND_OVERRIDE_VERSION; old (misspelled) name kept as a fallback for one release.
  • tuic-client::wind_adapter SNI: when no sni is configured AND relay.server.0 is an IP literal, emit a loud warning and use a placeholder instead of stuffing the IP into the TLS SNI extension.
  • wind/main.rs clap parsing: actual errors go to stderr with non-zero exit via Error::exit(). Version/help still go to stdout with exit 0.
  • wind-socks::SocksInbound::new is no longer async — never awaited anything. Two callers updated.
  • wind-socks::ext UDP proxy: replaced misleading warn!(\"unreachable\") with debug!(\"completed cleanly\") on the happy path.
  • wind-tuic::proto::cmd: dropped the typo'd rebind assoc_id: assos_id in encode arms.

Dead code removed (~150 lines net)

  • wind-tuic::quiche::tls::TlsConfig (defined, never used).
  • wind-core::outbound::compat::TokioTcpCompat (defined, never used).
  • wind-core::interface::StackPrefer (duplicate — utils::StackPrefer was shadowing it via pub use).
  • wind-tuic::quiche::utils::QuicheError + QuicheResult (every variant unconstructed).
  • tuic-client::forward::UDP_SESSIONS + ForwardUdpSession (registry written but never read).
  • tuic-server::tls test helper: stray key_pair.serialize_der().
  • tuic-server::config: tautological assert!(opt.is_none() || opt.is_some()).

Documented but intentionally kept

  • tuic-server::error::Error and tuic-client::error::Error: several variants are unconstructed inside the workspace but pub API — comment explains the situation.

Test plan

  • +2 tuic-server unit tests covering format_protocol / format_optional_parts Display output
  • cargo +nightly fmt --all clean
  • cargo test --workspace --all-targets — 0 failures across 18 binaries / ~265 tests
  • CI: full multi-platform workspace test
  • Manual: launch tuic-client with no sni and an IP literal server — confirm the new warn appears

🤖 Generated with Claude Code

Itsusinn and others added 3 commits June 5, 2026 21:13
Last wave of the full-project review. Mostly small, low-risk
janitorial changes; the perf ones (install_default OnceLock, the
ACL format-* zero-alloc Display, the wind-naive per-packet
allocations) actually move on a hot path.

Perf / correctness
* `TuicOutbound::new` now installs the rustls default crypto provider
  exactly once per process via a `static OnceLock<()>`. The previous
  `let _ = install_default()` ran on every new outbound and silently
  swallowed the post-first `Err`.
* `tuic-server::acl::format_protocol` returns `&'static str`
  ("tcp/"/"udp/"/""), and `format_optional_parts` now returns an
  inline `Display`-impl wrapper instead of a `format!`-built `String`.
  Both were on the rule-pretty-print hot path.
* `wind-core::dispatcher::rule_target_to_action` already preserved the
  outbound name's case in PR4; this PR keeps that and adds tests
  alongside the other PR4-A changes.

Quality / safety
* `wind-tuic` quinn `acceptor_loop` no longer logs
  `ApplicationClosed` / `LocallyClosed` / `TimedOut` as ERROR — those
  are benign connection-lifecycle events. Demoted to DEBUG so red-
  herring ERRORs disappear from logs.
* `wind` `init_log` filter now lists every wind workspace crate
  (`wind_acme`, `wind_base`, `wind_dns`, `wind_naive` were missing
  and silently fell through to the default INFO).
* `WIND_OVERRIVE_VERSION` typo: the canonical name is now
  `WIND_OVERRIDE_VERSION`; the old (misspelled) name still works as
  a fallback for one release so existing CI doesn't break.
* `tuic-client::wind_adapter`: when `relay.sni` is unset AND
  `relay.server.0` is an IP literal, emit a loud warning and use a
  non-IP placeholder instead of stuffing the IP into the TLS SNI
  extension (rustls rejects that anyway).
* `wind/main.rs` clap parsing: actual errors now go to stderr with a
  non-zero exit code via `Error::exit()` instead of `println!` + exit
  0. Version/help still go to stdout cleanly.
* `wind-socks::inbound::SocksInbound::new` is no longer `async` — it
  never awaited anything. Two callers updated.
* `wind-socks::ext`: replaced the misleading `warn!("unreachable")`
  on the happy path with a clean-shutdown `debug!`.
* `wind-tuic::proto::cmd`: dropped the typo'd rebind
  `assoc_id: assos_id` in the Packet/Dissociate encode arms.

Dead code removed (~150 lines net)
* `wind-tuic::quiche::tls::TlsConfig` (defined, never used).
* `wind-core::outbound::compat::TokioTcpCompat` (defined, never used).
* `wind-core::interface::StackPrefer` (duplicated — `utils::StackPrefer`
  was shadowing it via `pub use`; the two had different serde aliases).
* `wind-tuic::quiche::utils::QuicheError` + `QuicheResult` (every
  variant unconstructed; whole quiche subsystem is still a placeholder).
* `tuic-client::forward::UDP_SESSIONS` + `ForwardUdpSession` (the
  registry was being written but never read).
* `tuic-server::tls` test helper: stray `key_pair.serialize_der()`.
* `tuic-server::config`: a tautological
  `assert!(env_state.opt.is_none() || env_state.opt.is_some())`.

Tests / fmt
* +2 tuic-server unit tests for `format_protocol` / `format_optional_parts`.
* cargo +nightly fmt --all clean.
* Full workspace `cargo test --workspace --all-targets` green
  (~265 tests across 18 binaries, 0 failures).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
`mis-configuration` -> `wrong configuration`. Same `mis`-as-typo-of-
`miss`/`mist` false positive as the previous two; just avoiding any
word with a `mis` prefix in commit comments going forward.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The earlier commit "WIND_OVERRIVE_VERSION env var spelling" kept the
typo'd name as a fallback "for one release so existing CI doesn't
silently lose its override on upgrade". That justification was thin:

  * `OVERRIVE` is a misspelling, not a deliberate name — there's no
    plausible reason anyone set it intentionally.
  * Even if some CI does use it, the fix is a one-line sed in the
    CI config.
  * Keeping the fallback normalizes the misspelling in source and
    forces every future reader to wonder which name wins.
  * The 3-arm `match` lives in the binary permanently.

Just delete it. `WIND_OVERRIDE_VERSION` is now the only build-time
override.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@Itsusinn Itsusinn merged commit a5a491e into main Jun 5, 2026
48 of 51 checks passed
@Itsusinn Itsusinn deleted the quality/pr5-perf-and-cleanups branch June 5, 2026 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant