-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Very slow "Use item" menu #35292
Comments
That's quite a lot of items. |
The attached save link is no longer available, but I can still reproduce this in 0.E-6107-g 973dd89
|
So I tried adding a simple cache to mutable std::unordered_map<const item*, std::string> denial_cache; And it speeds up activation menu opening at least by half (1.1 seconds -> 0.5 seconds). @KorGgenT, can you evaluate this idea? I'm not sure about the lifetime of |
I tried spawning 10 of every item and opening the use item menu, it opens instantaneously. Did we have some major improvements to this or am I attempting to reproduce the issue incorrectly? EDIT: Ok so I went overboard and did "spawn every item" 9 times in a grid so I would be surrounded by items in all directions, and I definitely can see some slowdown now, though it's a fraction of a second. Now that I'm code diving, doing "one of every item" instead of "10 of every item" is what made the difference, because it's only looking at adjacent tiles anyway. |
@Aivean the lifetime of pickup_inventory_preset (or any of the inventiry_preset subclasses) is a single invocation of game_menus::inv::use(), so yes accumulating in a simple map should be safe. |
Other than Aivean's proposal, this needs pervasive nested item caching, which isn't a reasonable thing to try and shim in before 0,F |
Describe the bug
Pressing 'a' for use item menu in attached save takes ~7 seconds for menu to open.
I have managed to locate what is causing the slowness.
line 261 currently
adding simple return on the beginning of that method makes the action almost instant
I don't know what it does exactly but I think it gathers and checks whole new inventory from all items around. And it does it for all items(?).
Steps To Reproduce
Steps to reproduce the behavior:
Expected behavior
It should take far less time to open that menu.
Versions and configuration
Additional context
save
The text was updated successfully, but these errors were encountered: