Skip to content

Reduce RAM usage by caching single-stat Power Report scores - #10656

Open
AdamZ-8113 wants to merge 1 commit into
PathOfBuildingCommunity:devfrom
AdamZ-8113:perf/power-report-score-only-cache
Open

AdamZ-8113 wants to merge 1 commit into
PathOfBuildingCommunity:devfrom
AdamZ-8113:perf/power-report-score-only-cache

Conversation

@AdamZ-8113

Copy link
Copy Markdown
Contributor

Description of the problem being solved:

Power Reports can use several GB of RAM because PoB keeps the full calculation output for each passive it scores.

cache[key] = {
    TotalDPS = 4146952.522,
    AverageDamage = 434995.020,
    Speed = 9.533,
    FullDPS = 16514093.372,
    Life = 4734,
    EnergyShield = 330,
    FireResist = 75,
    TotalEHP = 50836.661,
    SkillDPS = {
        { name = "Storm Burst of Repulsion", count = 4, dps = 4128523.343 },
    },
    -- Hundreds of other fields
}

A single-stat report like Hit DPS only needs the signed gain for that stat.

cache[key] = 44911.445486031  -- +44,911.445 Hit DPS

This PR caches that number so Lua can free the full output sooner.

The combined Offence/Defence heat map still needs several stats and keeps the full outputs. Multi-node paths still get a full calculation for the whole path. Other features like support gem sorting, item comparisons, anoints, and the Compare tab, still get full output from the shared calculator.

Steps taken to verify a working solution:

Ran each report in a fresh desktop PoB process with the same build, loadout, tree, and depth.

Configuration Storm Burst 3.30
Hit DPS, depth All
Storm Burst 3.30
Full DPS, depth 10
Penance Brand 3.30
Life, depth All
Clean upstream/dev (c93b63b49) 24.36 s / 3.69 GiB 19.20 s / 2.96 GiB 22.84 s / 3.33 GiB
Clean dev + this PR 24.02 s / 1.80 GiB 19.33 s / 1.77 GiB 21.48 s / 1.72 GiB
Clean dev + this PR + performance stack 9.86 s / 1.91 GiB 12.72 s / 1.77 GiB 18.34 s / 1.73 GiB

The performance stack skips unneeded Full DPS and eHP work (#10313), skips unused cluster calculations (#10373), skips nodes that cannot affect the score (#10383), and avoids a duplicate Full DPS skill calculation (#10631). It also includes the passive cache-key fix which is critical for testing correctness (#10381).

  • This PR alone cut peak RAM by 40–51% in the three reports above. All 10,678 report rows matched across all three configurations. The standalone PR passed 928 tests.
  • Across 10 builds, toggling this cache on the same performance stack cut median peak RAM by 48.7%, with 0.0% median change in scan time. All 97 completed comparisons matched, including 66 single-stat reports, 5 combined heat maps, and 26 sort or filter checks.
  • The highest RAM peak was on Penance Brand. Running Hit DPS, Effective Hit Pool, and Life at depth All in the same session peaked at 6.7 GB with the cache off and 1.61 GB with it on.
image
  • The video shows clean dev versus the full stack. Storm Burst Hit DPS at depth All went from 29.01 s to 11.77 s, a 59% reduction, with all 3,693 rows matching.
hit-dps-power-report-comparison.mp4

This is portable to PoB2 although because of how modKey works in PoB2 I don't ever observe as significant of RAM usage.

Link to a build that showcases this PR:

Before screenshot:

After screenshot:

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.

1 participant