[PR #7055] perf(logging): aggregate disabled-client logs in Xray config generation #6623

Open
opened 2026-11-07 14:34:12 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/7055
Author: @HamedSanaei
Created: 11/3/2026
Status: 🔄 Open

Base: main ← Head: perf/xray-config-log-aggregation-7054


📝 Commits (1)

  • b710c84 perf(logging): aggregate disabled-client logs in Xray config generation

📊 Changes

3 files changed (+210 additions, -1 deletions)

View changed files

📝 internal/web/service/xray.go (+9 -1)
📝 internal/web/service/xray_config_clients_test.go (+154 -0)
📝 internal/web/service/xray_config_scale_test.go (+47 -0)

📄 Description

Summary

Replace per-client INFO messages during Xray configuration generation with one aggregate containing the number of excluded client entries and affected inbounds. Keep the existing filtering condition, generated configuration, traffic enforcement and runtime/restart behavior.

Why

Fixes #7054

GetXrayConfig() logged every entry rejected by the traffic-enabled lookup on every generation, including unchanged configurations. Each message also entered the panel's in-memory log buffer; moving it to DEBUG would still fill that buffer. The message described a removal even though this path only filters the generated configuration.

The counters are local to each generation. A successful generation with exclusions emits one INFO summary, containing counts only; a generation with no exclusions or a failed generation emits no summary. A client attached to multiple inbounds counts once per excluded entry.

This branch starts at upstream main (eae4725d) and contains no commits from #7012 or #7014.

Type of change

  • Bug fix
  • New feature
  • Refactoring (no behavior change)
  • Documentation
  • Tests only
  • Build / CI / tooling
  • Other: logging performance

Areas affected

  • Frontend (UI / panel pages)
  • Backend (API endpoints, login, settings)
  • Xray config generation
  • Subscription (share links / Clash / JSON)
  • Statistics / traffic counters
  • Database / migrations
  • Install / upgrade script
  • Docker image
  • Multi-node (sub-nodes)
  • Telegram bot

How was this tested?

Regression tests use the existing SQLite/scale fixtures and the actual logger buffer. They cover 2,000 excluded entries across five inbounds, mixed clients, unaffected inbounds, manual disablement, shared clients, zero exclusions, repeated generations, exact complete configuration comparison, identifier privacy, and failure after filtering but before configuration generation completes. The new regression tests were run against the base implementation and failed on its per-client messages; they pass with the fix.

  • Focused configuration regressions: passed.
  • make test-go: passed.
  • make verify: passed (including all 2,045 frontend tests in 222 files, generated artifacts, linters, typecheck, Go/frontend builds, Storybook build and docs OpenAPI parity).
  • make race: passed across the full Go suite, with no detected data races.
  • git diff --check: passed.

Measured performance

Compared upstream eae4725d with this fix using the same benchmark and normalized 2,000-client fixture across five local VLESS inbounds, all excluded by the traffic lookup. Measurements used Linux/WSL, Go 1.27.3, an Intel i7-1185G7, and five samples of 20 generations each. The existing scale logger configuration suppresses console INFO while file logging and the in-memory buffer remain active. Fixture setup and log-volume inspection are outside the timed loop.

Metric per generation Before After
Log entries 2,000 1
Formatted buffer-log bytes, including newlines 202,000 106
Median configuration generation 44.76 ms 43.08 ms
Timing range across samples 40.71–49.37 ms 39.73–45.53 ms
Median allocated bytes 15,122,833 12,374,464
Median allocations 220,687 178,723

Timing ranges overlap. These measurements quantify log volume, allocations and local elapsed time; production CPU utilization was not measured.

Reproduce on each version with the benchmark added by this PR:

XUI_DB_TYPE=sqlite XUI_SCALE_TEST=1 go test ./internal/web/service -run '^$' \
  -bench '^BenchmarkGetXrayConfigDisabledClients$' -benchtime=20x -count=5

Breaking changes

None. Database schema, HTTP APIs, runtime operations and node synchronization are unchanged.

Checklist

  • I tested the change locally and confirmed the described behavior.
  • I added or updated tests for the new behavior (when applicable).
  • go build ./... and the test suite pass locally.
  • For frontend changes: npm run lint, npm run typecheck, and npm run build pass. (No frontend changes.)
  • I updated the Wiki / README / API docs if user-facing behavior changed. (No UI/API changes; the new log format is described above.)
  • My commits follow the project's existing message style.
  • I have no unrelated changes mixed into this PR.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/MHSanaei/3x-ui/pull/7055 **Author:** [@HamedSanaei](https://github.com/HamedSanaei) **Created:** 11/3/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `perf/xray-config-log-aggregation-7054` --- ### 📝 Commits (1) - [`b710c84`](https://github.com/MHSanaei/3x-ui/commit/b710c840fcf22b692aca5d8f831d1ca63351bd22) perf(logging): aggregate disabled-client logs in Xray config generation ### 📊 Changes **3 files changed** (+210 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `internal/web/service/xray.go` (+9 -1) 📝 `internal/web/service/xray_config_clients_test.go` (+154 -0) 📝 `internal/web/service/xray_config_scale_test.go` (+47 -0) </details> ### 📄 Description ## Summary Replace per-client INFO messages during Xray configuration generation with one aggregate containing the number of excluded client entries and affected inbounds. Keep the existing filtering condition, generated configuration, traffic enforcement and runtime/restart behavior. ## Why Fixes #7054 `GetXrayConfig()` logged every entry rejected by the traffic-enabled lookup on every generation, including unchanged configurations. Each message also entered the panel's in-memory log buffer; moving it to DEBUG would still fill that buffer. The message described a removal even though this path only filters the generated configuration. The counters are local to each generation. A successful generation with exclusions emits one INFO summary, containing counts only; a generation with no exclusions or a failed generation emits no summary. A client attached to multiple inbounds counts once per excluded entry. This branch starts at upstream `main` (`eae4725d`) and contains no commits from #7012 or #7014. ## Type of change - [x] Bug fix - [ ] New feature - [ ] Refactoring (no behavior change) - [ ] Documentation - [ ] Tests only - [ ] Build / CI / tooling - [x] Other: logging performance ## Areas affected - [ ] Frontend (UI / panel pages) - [ ] Backend (API endpoints, login, settings) - [x] Xray config generation - [ ] Subscription (share links / Clash / JSON) - [ ] Statistics / traffic counters - [ ] Database / migrations - [ ] Install / upgrade script - [ ] Docker image - [ ] Multi-node (sub-nodes) - [ ] Telegram bot ## How was this tested? Regression tests use the existing SQLite/scale fixtures and the actual logger buffer. They cover 2,000 excluded entries across five inbounds, mixed clients, unaffected inbounds, manual disablement, shared clients, zero exclusions, repeated generations, exact complete configuration comparison, identifier privacy, and failure after filtering but before configuration generation completes. The new regression tests were run against the base implementation and failed on its per-client messages; they pass with the fix. - Focused configuration regressions: passed. - `make test-go`: passed. - `make verify`: passed (including all 2,045 frontend tests in 222 files, generated artifacts, linters, typecheck, Go/frontend builds, Storybook build and docs OpenAPI parity). - `make race`: passed across the full Go suite, with no detected data races. - `git diff --check`: passed. ### Measured performance Compared upstream `eae4725d` with this fix using the same benchmark and normalized 2,000-client fixture across five local VLESS inbounds, all excluded by the traffic lookup. Measurements used Linux/WSL, Go 1.27.3, an Intel i7-1185G7, and five samples of 20 generations each. The existing scale logger configuration suppresses console INFO while file logging and the in-memory buffer remain active. Fixture setup and log-volume inspection are outside the timed loop. | Metric per generation | Before | After | | --- | ---: | ---: | | Log entries | 2,000 | 1 | | Formatted buffer-log bytes, including newlines | 202,000 | 106 | | Median configuration generation | 44.76 ms | 43.08 ms | | Timing range across samples | 40.71–49.37 ms | 39.73–45.53 ms | | Median allocated bytes | 15,122,833 | 12,374,464 | | Median allocations | 220,687 | 178,723 | Timing ranges overlap. These measurements quantify log volume, allocations and local elapsed time; production CPU utilization was not measured. Reproduce on each version with the benchmark added by this PR: ```sh XUI_DB_TYPE=sqlite XUI_SCALE_TEST=1 go test ./internal/web/service -run '^$' \ -bench '^BenchmarkGetXrayConfigDisabledClients$' -benchtime=20x -count=5 ``` ## Breaking changes None. Database schema, HTTP APIs, runtime operations and node synchronization are unchanged. ## Checklist - [x] I tested the change locally and confirmed the described behavior. - [x] I added or updated tests for the new behavior (when applicable). - [x] `go build ./...` and the test suite pass locally. - [ ] For frontend changes: `npm run lint`, `npm run typecheck`, and `npm run build` pass. (No frontend changes.) - [ ] I updated the Wiki / README / API docs if user-facing behavior changed. (No UI/API changes; the new log format is described above.) - [x] My commits follow the project's existing message style. - [x] I have no unrelated changes mixed into this PR. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#6623
No description provided.