mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-08-20 10:00:58 +00:00
perf(metrics): tiered rollup history (7d at ~1.5MB) and cleaner ranges
Replace the flat 48h@2s ring buffer with a 3-tier rollup ladder (2s/1h, 1m/48h, 10m/7d). A sample feeds every tier and rolls up into progressively coarser averages, so per-metric footprint drops from ~21MB to ~1.5MB (measured, 16 system metrics) while extending the range from 48h to 7 days. aggregate() picks the finest tier covering the requested span; a pre-tier flat gob is migrated by replaying its samples through the rollup. Tidy the dashboard ranges to a professional ladder: 2m, 1h, 3h, 6h, 12h, 24h, 2d, 7d (drop the irregular 2h/5h, the redundant 30m, and the excessive 30d). The allow-list keeps bucket 30 because the node history panel uses it. Add an initial FreeOSMemory about 60s after boot to reclaim the startup and metric-restore peak instead of waiting for the periodic release. Cover the rollup, tier selection, round-trip, and footprint with tests.
This commit is contained in:
@@ -166,15 +166,15 @@ const xrayVersionsCacheTTL = 15 * time.Minute
|
||||
// callers from triggering arbitrary aggregation work and keeps the
|
||||
// frontend's bucket selector self-documenting.
|
||||
var allowedHistoryBuckets = map[int]bool{
|
||||
2: true, // Real-time view
|
||||
30: true, // 30s intervals
|
||||
60: true, // 1m intervals
|
||||
120: true, // 2m intervals
|
||||
180: true, // 3m intervals
|
||||
300: true, // 5m intervals
|
||||
720: true, // 12m intervals
|
||||
1440: true, // 24m intervals
|
||||
2880: true, // 48m intervals
|
||||
2: true, // 2m
|
||||
30: true, // 30m
|
||||
60: true, // 1h
|
||||
180: true, // 3h
|
||||
360: true, // 6h
|
||||
720: true, // 12h
|
||||
1440: true, // 24h
|
||||
2880: true, // 2d
|
||||
10080: true, // 7d
|
||||
}
|
||||
|
||||
// IsAllowedHistoryBucket reports whether a bucket-seconds value is in the
|
||||
|
||||
Reference in New Issue
Block a user