perf(nodes): avoid materializing reset history in lists - #851
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Team Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (5)
Included review availability: Your plan provides up to 8 included reviews per hour; 6 remain after this review. WalkthroughNode lifetime usage can now load as correlated aggregates without loading usage-log history. The WEB node-list operation uses this mode. Tests and a benchmark validate totals, loading behavior, SQL activity, memory, and runtime. ChangesNode lifetime usage aggregation
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to Node list views now calculate lifetime traffic through database aggregates without loading reset-history objects, preserving reported totals while reducing list-query resource use. No merge-blocking risk remains. Sequence Diagram(s)sequenceDiagram
participant WEB NodeOperation
participant get_nodes
participant NodeUsageResetLogs
WEB NodeOperation->>get_nodes: Request lifetime usage without usage logs
get_nodes->>NodeUsageResetLogs: Sum uplink and downlink per node
NodeUsageResetLogs-->>get_nodes: Return correlated totals
get_nodes-->>WEB NodeOperation: Return nodes with lifetime usage values
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
Summary
The dashboard node list is polled every 10 seconds. It previously
selectinloaded everyNodeUsageResetLogsrow for the page and materialized those rows as ORM objects just to calculatelifetime_uplinkandlifetime_downlink.This change:
SUMexpressions in the node queryNot a duplicate
I checked all local/remote branches and open PRs for node list/reset-history aggregation. No existing change implements this. In particular, #615 targets pools, indexes, usage writes, and health checks; #724 fixed N+1 loading by eagerly loading relations but still materializes the complete node reset history.
Benchmark
Command:
python -m scripts.benchmark_node_list_usageSQLite in-memory, matching the dashboard page size of 15 nodes, with 1,000 reset records per node; median of 5 timed runs:
The benchmark also asserts that lifetime usage is identical in both paths.
Verification
git diff --check: passedThe local API test harness remains blocked by its existing database setup: the on-disk test DB references missing Alembic revision
a4d8c7e91b32, while the in-memory override creates tables on a connection different from the app session (no such table: jwt).Summary by CodeRabbit
New Features
Performance Improvements
Bug Fixes