[Core] Refactor NodeHead module by optimizing flow insight dependency imports to load only when enabled#751
[Core] Refactor NodeHead module by optimizing flow insight dependency imports to load only when enabled#751daiping8 wants to merge 2 commits intoantgroup:mainfrom
Conversation
…ate conversion logic inline. Optimize flow insight dependency imports to load only when enabled. This improves code clarity and performance. Change-Id: I6f2ab36769aad55df6914d18345e8ab572e31fd7
There was a problem hiding this comment.
Code Review
This pull request refactors the NodeHead module to lazily import dependencies for flow insight and autoscaler logic. This is a great optimization to reduce the memory footprint and startup time of the dashboard subprocesses. The changes correctly move imports into the functions where they are used and add checks to only load dependencies when the features are enabled.
I've found one critical issue in the legacy autoscaler code path where a None value could be passed to a function that doesn't expect it, leading to a crash. I've provided a suggestion to fix this.
Overall, the refactoring is well-executed and improves the performance of the dashboard.
…ing logical resources are only retrieved when usage data is available. Added a smoke test for the autoscaler v2 branch to prevent NameError regressions. This improves stability and test coverage. Change-Id: I7a588cbcb6ebb347b5b89c0416e28f1e266443bc
|
This pull request has been automatically marked as stale because it has not had You can always ask for help on our discussion forum or Ray's public slack channel. If you'd like to keep this open, just leave any comment, and the stale label will be removed. |
|
keep alive |
Motivation
NodeHead, as one of the dashboard subprocesses, currently loads a batch of dependencies at process startup that are only needed in specific feature scenarios (especially flow/insight and some autoscaler helper logic). Changing to lazy loading can reduce the base memory footprint of each NodeHead subprocess and shorten import time during startup; in clusters, these savings are amplified by the number of subprocesses.
Changes
_emit_node_physical_stats(), importing them only wheninsight_monitor_addressis detected and the feature is enabled._to_service_stateto a local functionto_service_stateinside_emit_node_physical_stats(), avoiding top-level symbol coupling for optional dependencies.Unit Tests
is_autoscaler_v2=True)ClusterStatusParser.from_get_cluster_status_replyandparse_usageparse_usageImpact
NodeHead RSS reduced by approximately 10MB
Statistics Script