Skip to content

Commit fd93509

Browse files
vahidlazioclaude
andcommitted
feat: remove pipeline depth cap — scales with deployment count
Pipeline depth was artificially capped at 12. Users with 20+ deployments across multiple accounts were wasting pipeline capacity. Now: pipeline_depth = num_scripts (minimum 2, no upper cap). The connection pool (80) is the natural ceiling. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 3a640fb commit fd93509

3 files changed

Lines changed: 10 additions & 12 deletions

File tree

‎README.md‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,15 +271,16 @@ Full tunnel mode (`"mode": "full"`) routes **all** traffic end-to-end through Ap
271271
Each Apps Script batch request takes ~2 seconds round-trip. In full mode, `mhrv-rs` runs a **pipelined batch multiplexer** that fires multiple batch requests concurrently without waiting for the previous one to return. The number of in-flight batches (the *pipeline depth*) scales directly with the number of deployment IDs you configure:
272272

273273
```
274-
pipeline_depth = number_of_script_ids (clamped to 2..12)
274+
pipeline_depth = number_of_script_ids (minimum 2)
275275
```
276276

277277
| Deployments | Pipeline depth | Effective batch interval | Notes |
278278
|-------------|---------------|------------------------|-------|
279279
| 1 | 2 | ~1.0s | Minimum — still pipelines 2 batches |
280280
| 3 | 3 | ~0.7s | Good for light browsing |
281281
| 6 | 6 | ~0.3s | Recommended for daily use |
282-
| 12 | 12 | ~0.17s | Maximum — diminishing returns past this |
282+
| 12 | 12 | ~0.17s | Sweet spot for most users |
283+
| 20 | 20 | ~0.10s | Multi-account setups |
283284

284285
More deployments = more concurrent batches = lower per-session latency. Each batch round-robins across your deployment IDs, so the load is spread evenly and you're less likely to hit a single deployment's quota ceiling.
285286

@@ -618,15 +619,16 @@ Original project: <https://github.com/masterking32/MasterHttpRelayVPN> by [@mast
618619
هر درخواست دسته‌ای (`batch`) به `Apps Script` حدود ۲ ثانیه طول می‌کشد. در حالت `full`، برنامه یک **لولهٔ موازی** (`pipeline`) اجرا می‌کند که چند درخواست دسته‌ای را همزمان می‌فرستد بدون اینکه منتظر پاسخ قبلی بماند. تعداد درخواست‌های همزمان مستقیماً با تعداد `Deployment ID`ها رابطه دارد:
619620

620621
```
621-
عمق لوله = تعداد Deployment IDها (حداقل ۲، حداکثر ۱۲)
622+
عمق لوله = تعداد Deployment IDها (حداقل ۲)
622623
```
623624

624625
| تعداد Deployment | عمق لوله | فاصلهٔ مؤثر بین دسته‌ها | |
625626
|-----------------|----------|------------------------|---|
626627
| ۱ | ۲ | ~۱ ثانیه | حداقل |
627628
| ۳ | ۳ | ~۰.۷ ثانیه | مناسب مرور سبک |
628629
| ۶ | ۶ | ~۰.۳ ثانیه | توصیه‌شده برای استفادهٔ روزانه |
629-
| ۱۲ | ۱۲ | ~۰.۱۷ ثانیه | حداکثر |
630+
| ۱۲ | ۱۲ | ~۰.۱۷ ثانیه | نقطهٔ بهینه |
631+
| ۲۰ | ۲۰ | ~۰.۱ ثانیه | چند حساب |
630632

631633
بیشتر `Deployment` = بیشتر درخواست همزمان = تأخیر کمتر برای هر نشست. هر دسته بین `ID`ها چرخش می‌کند (`round-robin`)، پس بار به‌طور یکنواخت توزیع می‌شود.
632634

‎src/tunnel_client.rs‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
//!
33
//! A central multiplexer collects pending data from ALL active sessions
44
//! and fires batch requests without waiting for the previous one to return.
5-
//! Pipeline depth scales with the number of script deployments (1 per
6-
//! script, clamped to 2..12), so users with more deployments get lower
7-
//! latency automatically.
5+
//! Pipeline depth equals the number of script deployments (minimum 2),
6+
//! so users with more deployments get lower latency automatically.
87
98
use std::sync::Arc;
109
use std::time::Duration;
@@ -17,8 +16,6 @@ use tokio::sync::{mpsc, oneshot, Semaphore};
1716

1817
use crate::domain_fronter::{BatchOp, DomainFronter, TunnelResponse};
1918

20-
/// Hard ceiling on pipeline depth regardless of script count.
21-
const MAX_PIPELINE_DEPTH: usize = 12;
2219
/// Minimum pipeline depth even with a single script.
2320
const MIN_PIPELINE_DEPTH: usize = 2;
2421

@@ -69,8 +66,7 @@ pub struct TunnelMux {
6966

7067
impl TunnelMux {
7168
pub fn start(fronter: Arc<DomainFronter>) -> Arc<Self> {
72-
let pipeline_depth =
73-
fronter.num_scripts().clamp(MIN_PIPELINE_DEPTH, MAX_PIPELINE_DEPTH);
69+
let pipeline_depth = fronter.num_scripts().max(MIN_PIPELINE_DEPTH);
7470
tracing::info!(
7571
"tunnel mux: pipeline_depth={} (from {} script deployments)",
7672
pipeline_depth,

‎tunnel-node/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ TUNNEL_AUTH_KEY=your-secret PORT=8080 ./target/release/tunnel-node
8282

8383
## Performance: deployment count and pipeline depth
8484

85-
The mhrv-rs client runs a pipelined batch multiplexer in full mode. Each Apps Script round-trip takes ~2s, so the client fires multiple batch requests concurrently — the pipeline depth equals the number of configured script deployment IDs (clamped 2..12).
85+
The mhrv-rs client runs a pipelined batch multiplexer in full mode. Each Apps Script round-trip takes ~2s, so the client fires multiple batch requests concurrently — the pipeline depth equals the number of configured script deployment IDs (minimum 2, no upper cap).
8686

8787
More deployments = more concurrent batches hitting the tunnel-node = lower per-session latency. With 6 deployments, a new batch arrives every ~0.3s instead of every 2s.
8888

0 commit comments

Comments
 (0)