Skip to content

Refactor/11850 Flow_threads refactor: unify recycler and manager computation v1 - #38

Closed
KEIAHNY wants to merge 1 commit into
mainfrom
11850-refactor-flow_threads-v1
Closed

KEIAHNY wants to merge 1 commit into
mainfrom
11850-refactor-flow_threads-v1

Conversation

@KEIAHNY

@KEIAHNY KEIAHNY commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator

PR Type

Enhancement


Description

  • Extract shared get_up_windows helper for both computations

  • Extract get_window_cpu_average_vector CPU averaging helper

  • Parameterize threshold comparison via above flag

  • Reset up flag per iteration; minor formatting fixes


Diagram Walkthrough

flowchart LR
  A["get_recycler_count"] -- "HUBER_THRESHOLD, above=true" --> C["get_up_windows"]
  B["get_flow_mgr_count"] -- "MANAGER_SLOPE, above=false" --> C
  C -- "delegates CPU averaging" --> D["get_window_cpu_average_vector"]
Loading

File Walkthrough

Relevant files
Enhancement
flow_threads.rs
Unify recycler and manager window computation logic           

src/flow_threads.rs

  • Extract duplicated window-scanning loop into generic get_up_windows
    helper
  • Add above boolean to support both > (recycler) and < (manager)
    threshold checks
  • Extract CPU averaging logic into get_window_cpu_average_vector helper
  • Reset up flag at each loop iteration; fix brace indent and EOF newline
+67/-103

@KEIAHNY KEIAHNY self-assigned this Oct 12, 2026
@KEIAHNY KEIAHNY changed the title Refactor/11850 Flow_threads refactor: unify recycler and manager computation Refactor/11850 Flow_threads refactor: unify recycler and manager computation v1 Oct 12, 2026
@github-actions

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Dropped CPU check

The unified get_up_windows no longer enforces the CPU_USAGE_MAX condition that existed in the old manager (get_flow_mgr_count) path. Previously, a manager window only counted as "up" if avg > CPU_USAGE_MAX; now only the slope threshold (above=false, MANAGER_SLOPE) is checked. The avg value is still computed (and is now dead code, which the compiler will warn about), confirming the check was accidentally removed during unification. This changes behavior: mgr_power can now be computed from low-CPU windows that were previously excluded, potentially producing incorrect flow manager counts.

let avg: f32 = avg_cpu_usage[(sm_counter * (avg_cpu_usage.len()/WINDOWS as usize)) ..
    ((sm_counter + 1) * (avg_cpu_usage.len()/WINDOWS as usize))]
    .iter().sum::<f32>() / (avg_cpu_usage.len()/WINDOWS as usize) as f32;
sm_counter+=1;

if (above && current_window > &threshold) || (!above && current_window < &threshold) {
    tmp_slope_vector.push(*current_window);
    up &= true;

@github-actions

Copy link
Copy Markdown

Failed to generate code suggestions for PR

@KEIAHNY

KEIAHNY commented Oct 12, 2026

Copy link
Copy Markdown
Collaborator Author

Closing - failed pipeline.

@KEIAHNY KEIAHNY closed this Oct 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant