-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Slowdown when crafting items with lots of surrounding items in sight. #63586
Comments
Do not expect that - there could be a fire, a monster or an npc that would destroy any item any minute. |
Not sure if it is already doing this, but we can cache the item location of the last used tool and first check if the tool still exists and satisfies the requirements, and if not, look through the surrounding items again for the tool. |
Any solution that verifies that the tools and materials still exists in O(1) time is better than O(n) time. Caching their location is good idea, I hadn't thought of a fire reaching the tool while you're still crafting. Putting the items in an invisible inventory wouldn't work then. Having a listing for them separate from all the other items in view range may be the only way? |
This is especially bad with non-charged items, getting tailoring materials in significant quantities really hampers your IRL:game time for example. |
@CoroNaut for the record, the requested attached save was not "n/a" here; "anyone can do this" is not how you get issues addressed because how you go about things might not be how anyone else goes about things, and there might be something "obvious" that is subjective. in this case, it took quite a lot of time to successfully replicate the problem, and even further to narrow things down (like, i burnt well over two hours getting to the point i could post this). in the future please actually provide the information the form asks. this easily could have been closed for being an incomplete/nonactionable report, and it would have been perfectly correct to do so. |
The bottleneck in crafting in the save uploaded by @esotericist is in finding nearby lifting assists. Adding an early exit for small weight and volume item crafts avoids the performance problem, but crafting heavy or bulky items still suffers. diff --git a/src/crafting.cpp b/src/crafting.cpp
index 97904ed165..4a1495dc07 100644
--- a/src/crafting.cpp
+++ b/src/crafting.cpp
@@ -252,6 +252,10 @@ static float workbench_crafting_speed_multiplier( const Character &you, const it
const units::mass &craft_mass = craft.weight();
const units::volume &craft_volume = craft.volume();
+ if( craft_mass <= allowed_mass && craft_volume <= allowed_volume ) {
+ return multiplier;
+ }
+
units::mass lifting_mass = you.best_nearby_lifting_assist();
if( lifting_mass > craft_mass ) { A deeper solution is to cache nearby lifting assists so it doesn't need to be recomputed every turn. |
As of version "4f24d43", this is still very prominent. I can start a craft in an area with 1000 items and it will max out my CPU and takes 10 seconds for every 5 minute ingame interval. Moving to a new location around a wall where the 1000 items aren't in sight or available for crafting, the craft barely uses its alotted CPU resources and there is no in-game slowdown. |
@esotericist Given that this is an issue that all players experience in a spectrum, I didn't think it productive to provide a save file, since a slowdown happens on all save files to some degree. I will however provide a more indepth process in which to recreate the problem here. My current save file below: Lenora.zip Location 1 contains all the stuff I've gathered, almost 1000L of just random crap. If I start crafting the "20-round shotshell belt" in location 1, it will take 1 minute for my machine to progress 0 to 50% of the craft and max my CPU. If I then move to location 2 and continue the craft, it will take 2 seconds to progress 50% to 100%, and have no noticable effect on CPU. I also tried the "peasant flail" and "wooden tonfa", both with significantly less components to craft, and the slowdown happens all the same |
Describe the bug
When crafting objects with none, or very few items in view range around the player, there is little to no process slowdown. Essentially the time it takes to pass 5 in-game minutes is for example, 1 second real-time. Crafting objects while there are lots of items, 500+ in sight (inside the "list all objects around player" menu, ctrl-v) will essentially add real-time to the crafting. So 5 in-game minutes will become 2, 3, 5 seconds real-time.
I believe this is due to the crafting process needing to continually check every in-game second if the required materials are in range. If I however move all the required tools and materials around a wall, such that these 500+ items are out of view range, but still in the same map chunk, the crafting takes much less real-time.
For crafts taking more than 5 hours in-game, it can take a while as you see the crafting progress tick up 1% or less every real second.
Attach save file
Save file and additional details ***N/A. Anyone can plop down lots of loot and see the performance slowdown.
Steps to reproduce
Expected behavior
I expect the crafting process to not check every second if it is in range of tools and materials. The materials can just be consumed into the crafting recipe, while the tools only need to be checked once upon starting the craft from 0%, or any%. If the player needs to stop the craft and restart later, they set the in-progress craft down, then pick it up and re-check if the tools are present. Adding more loot around the player inside their view range should not increase the real-time to craft objects.
The player is locked on the spot while crafting. So to prevent the tools from wandering away, they can be put into an invisible inventory, or list, or something similar so that npc's cant take them, or they cant get destroyed by a meteor, or zombies don't break down walls and they get caved in on.
Ofcourse I haven't looked into the code as to how its handled. My observations may not represent the game's actual process for handling crafting. This is just how it looks and feels to a gamer.
Screenshots
No response
Versions and configuration
Dark Days Ahead [dda],
No Fungal Growth [no_fungal_growth]
]
Additional context
No response
The text was updated successfully, but these errors were encountered: