Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ItemRequirement rework #1847

Merged
merged 12 commits into from
Nov 23, 2024
Merged

ItemRequirement rework #1847

merged 12 commits into from
Nov 23, 2024

Conversation

Zoinkwiz
Copy link
Owner

This PR intends to improve the efficiency of ItemRequirement checks by including some caching where possible. I've tried to introduce the concept of cached containers (inventory, equipped, bank), which I hope will in the future make it easier for us to include new container concepts such as the rune pouch, POH storage, etc.

I've checked how long the checks take for the sidebar each tick for the Check all items helpers as it's the largest in terms of requirements. Generally across 1000 ticks the new method while cached is 2x faster on average. I've included a 100s sample below with in the cache, with the average for it being:

old: 3266746 ns
new: 1408209 ns

newDiff.txt
oldDiff.txt

We're not dealing with massive values in general, though I've also not encountered the lag spikes on my computer, so I'm going on the assumption for lower spec devices this will hopefully make a bigger difference.

I need to still add in some better comments and preferably some tests for this going forwards.

This attempts to add a level of caching to ItemRequirement, so that it doesn't regularly need to go deeper into checks when it already knows the answer.
Copy link
Contributor

@pajlada pajlada left a comment

Choose a reason for hiding this comment

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

small nits

Zoinkwiz and others added 9 commits November 21, 2024 23:22
Co-Authored-By: pajlada <962989+pajlada@users.noreply.github.com>
Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
Co-Authored-By: pajlada <962989+pajlada@users.noreply.github.com>
Co-Authored-By: pajlada <962989+pajlada@users.noreply.github.com>
Co-Authored-By: pajlada <962989+pajlada@users.noreply.github.com>
Co-Authored-By: pajlada <962989+pajlada@users.noreply.github.com>
Co-Authored-By: pajlada <962989+pajlada@users.noreply.github.com>
Co-Authored-By: pajlada <962989+pajlada@users.noreply.github.com>
Co-Authored-By: pajlada <962989+pajlada@users.noreply.github.com>
@Zoinkwiz Zoinkwiz merged commit d8a1b15 into master Nov 23, 2024
1 check passed
@Zoinkwiz Zoinkwiz deleted the itemrequirement-rework branch November 23, 2024 10:53
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