perf: size the workflow result map from Workflow#size - #3547
Conversation
AbstractWorkflowExecutor called Workflow#getDependentResourcesByName purely to read its size. That allocates a HashMap and walks every node to collect the dependent resources, then discards the map. The executor is constructed on every reconcile and cleanup of a workflow-based reconciler, so use the existing Workflow#size instead.
|
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: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
There was a problem hiding this comment.
Pull request overview
This PR reduces per-reconcile allocation overhead in the workflow execution path by avoiding creation of a dependent-resources map solely to pre-size the executor’s result map. It leverages DefaultWorkflow#size() (which is backed by dependentResourceNodes.size()) to keep behavior unchanged while eliminating unnecessary work.
Changes:
- Replace
workflow.getDependentResourcesByName().size()withworkflow.size()when initializingresultsinAbstractWorkflowExecutor. - Avoid allocating and populating a temporary
HashMapof dependent resources during executor construction.
AbstractWorkflowExecutor called Workflow#getDependentResourcesByName purely to
read its size. That allocates a HashMap and walks every node to collect the
dependent resources, then discards the map. The executor is constructed on
every reconcile and cleanup of a workflow-based reconciler, so use the existing
Workflow#size instead.
Quality-only change: no intended behavior difference. Cut from
nextandtouches a disjoint set of files from the sibling cleanup PRs, so it can be merged
independently and in any order.
Verified on this branch alone:
mvn -o -pl operator-framework-core,operator-framework-junit -am test(693 core + 6 junit tests, no failures) and
mvn spotless:check.