3x-ui/web
MHSanaei f185d3315c
perf(clients): scale add/delete and bulk client operations
Follow-up to the SyncInbound bulk rewrite, fixing the remaining O(M*N)
and O(M)-round-trip behaviour in the add/delete and bulk paths that made
them time out on large inbounds (worst case minutes), especially on
PostgreSQL.

- compactOrphans: chunk the "email IN (...)" lookup (400/batch) instead
  of binding every email at once. A single huge IN exceeded PostgreSQL's
  65535-parameter limit (and SQLite's) and made the planner pathological,
  so add/delete failed outright past ~100k clients.

- emailsUsedByOtherInbounds: new batched form used by delInboundClients
  (BulkDetach) and bulkDelInboundClients (BulkDelete), replacing a
  per-email global JSON scan (O(M*N)) with one scan, and skipped entirely
  when keepTraffic is set.

- BulkCreate: rewritten to validate/dedup in one pass, then group clients
  by inbound and add them in a single addInboundClient call per inbound
  (one getAllEmailSubIDs, one settings rewrite, one SyncInbound) instead
  of running the full single-create pipeline per client.

- Bulk delete/adjust: batch DelClientStat/DelClientIPs with IN deletes
  and wrap the settings Save + SyncInbound in one transaction, so the
  per-row writes share a single fsync instead of one per row.

Measured on PostgreSQL 16 (one inbound, M=2000 affected clients):
  - create: 8m35s (M=500) -> ~1-5s
  - detach: 52s -> ~4s (flat in N)
  - delete: ~16s -> ~1-4s
  - adjust: ~20s -> ~7-10s
add/delete of a single client on a 200k-client inbound stays in seconds.

sync_scale_postgres_test.go adds skip-gated benchmarks (XUI_DB_TYPE=
postgres) for the single add/delete and the five bulk operations.
2026-06-04 19:41:00 +02:00
..
controller fix(multi-node): scope remote client update/delete to one inbound (#4892) 2026-06-04 16:45:40 +02:00
entity fix(settings): allow pagination size of 0 to disable pagination 2026-06-02 14:54:11 +02:00
global Feat/multi inbound clients (#4469) 2026-05-19 12:20:24 +02:00
job fix(online): scope per-inbound online to inbounds that carried traffic 2026-06-03 16:19:00 +02:00
locale v3 2026-05-10 02:13:42 +02:00
middleware feat: complete Zod migration of frontend + bulk client batching (#4599) 2026-05-27 04:26:50 +02:00
network docs: add comments for all functions 2025-09-20 09:35:50 +02:00
runtime fix(multi-node): scope remote client update/delete to one inbound (#4892) 2026-06-04 16:45:40 +02:00
service perf(clients): scale add/delete and bulk client operations 2026-06-04 19:41:00 +02:00
session Security hardening: sessions, SSRF, CSP nonce, CSRF logout, trusted proxies (#4275) 2026-05-13 12:52:52 +02:00
translation feat(migrate-db): SQLite <-> .dump conversion and Download Migration in Overview 2026-06-04 15:32:22 +02:00
websocket fix(websocket): order register/unregister via single ops channel 2026-05-19 12:34:53 +02:00
web.go feat(dashboard): more System History metrics, persistence & localized labels 2026-06-03 12:16:31 +02:00