Skip to content

Loadout Optimizer: extract helpers to make the process loop readable - #11874

Open
delphiactual wants to merge 1 commit into
masterfrom
lo-process-readability
Open

Loadout Optimizer: extract helpers to make the process loop readable#11874
delphiactual wants to merge 1 commit into
masterfrom
lo-process-readability

Conversation

@delphiactual

Copy link
Copy Markdown
Contributor

Review feedback on #11868: the process worker had become hard to follow. Behavior-preserving cleanup of process.ts:

  • The four outer loop levels shared near-identical inline perk, set bonus, and stat accumulation code; that logic now lives in perkCountsPrune, setBonusPrune, and addItemStats, so each level reads as a uniform sequence of prune checks.
  • Cold setup code (bucket stat bounds, tuning delta bounds, exact stat range seeding, the Firefox yield workaround) moved out of process() into named top-level functions with their explanatory comments.
  • The five buildBucketSoA calls collapsed into a map over the buckets, and maxModBonus reuses the precomputed generalModsBonus.

No optimizations were removed. The parity suite passes unchanged, and the A/B bench reports the same speedups over the frozen baseline before and after (12.0/2.3/6.8x vs 12.3/2.4/6.8x on the three scenarios).

Review feedback on #11868: the process worker had become hard to follow. Behavior-preserving cleanup of process.ts:

- The four outer loop levels shared near-identical inline perk, set bonus, and stat accumulation code; that logic now lives in perkCountsPrune, setBonusPrune, and addItemStats, so each level reads as a uniform sequence of prune checks.
- Cold setup code (bucket stat bounds, tuning delta bounds, exact stat range seeding, the Firefox yield workaround) moved out of process() into named top-level functions with their explanatory comments.
- The five buildBucketSoA calls collapsed into a map over the buckets, and maxModBonus reuses the precomputed generalModsBonus.

No optimizations were removed. The parity suite passes unchanged, and the A/B bench reports the same speedups over the frozen baseline before and after (12.0/2.3/6.8x vs 12.3/2.4/6.8x on the three scenarios).

@bhollis bhollis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Certainly a readability improvement. I'm surprised function calls don't end up more expensive - that's why we'd inlined everything before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants