Skip to content

Cache unique database stat sort values - #10372

Open
AdamZ-8113 wants to merge 1 commit into
PathOfBuildingCommunity:devfrom
AdamZ-8113:perf/unique-sort-cache
Open

AdamZ-8113 wants to merge 1 commit into
PathOfBuildingCommunity:devfrom
AdamZ-8113:perf/unique-sort-cache

Conversation

@AdamZ-8113

Copy link
Copy Markdown
Contributor

Description of the problem being solved:

Sorting the unique item database by a calculated stat runs a calculation for every valid item and equipment slot. There is no caching currently, so rebuilding that same sorted list, including after changing its search filter (i.e. while typing or toggling item slots), currently repeats every calculation even when the build output hasn't changed.

This caches each unique item's calculated sort value until the build changes. Values are kept separately for each stat and item set, so repeated sorts and filter changes can reuse them without changing the initial calculation or its result.

Steps taken to verify a working solution:

  • On my build, a Hit DPS sort required 7,430 calculations and took 20.657 seconds baseline. Repeating the sort with this change implemented performs no additional calculations and takes 3.229 ms.
  • New regression test + full test suite
  • LLM compared full main, minion and Calcs-tab numeric outputs, plus complete gem and unique sort orders, before and after the change. The results were byte-identical
  • Manual testing

Link to a build that showcases this PR:

Before screenshot:

no-cache-sort

After screenshot:

cached-sorting

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