Cataclysm-dda: Hauling many items has poor performance

Created on 21 Oct 2019  Â·  13Comments  Â·  Source: CleverRaven/Cataclysm-DDA

Is your feature request related to a problem? Please describe.
Hauling items is very slow/feels stuttery when hauling a larger number of items.

Describe the solution you'd like
@ifreund and I spoke about this in the Discord, and came up with the idea of abstracting the movement of the items in the tile just like when sorting items in zones. This can be limited to one tile movement distance, or use a target tile - sort of like a temporary zone.

<Bug> <Enhancement / Feature> <Suggestion / Discussion> Performance Character / Player [C++]

All 13 comments

So, ACT_MOVE_ITEMS will actually already adjust the moves it consumes based on the distance each item is moved https://github.com/CleverRaven/Cataclysm-DDA/blob/7787bc041afa43883ee41bc38e70988c5d5e2d08/src/activity_item_handling.cpp#L756
This comes into play when, for example, using the advanced inventory to move an item 2 tiles at a time instead of just one.

What needs to happen to implement is most likely the creation of a new activity,ACT_HAUL_TO_TARGET or something of the sort, which allows the player to select a destination and automatically moves all items at the player's feet to the destination, moving each item in the largest jumps possible without taking the player below 0 moves.

There is however a potential exploit in this kind of abstraction, since the player could then for example "haul" a grenade or other item out into a group of zombies without the game ever simulating the player moving from their tile. This is already technically possible to do with zone sorting by the way though and It's unclear to me what the best solution would be.

The solution is to optimize whatever is making it slow, abstracting
movement is always going to cause problems.
I consider the teleporting around that item sorting does right now a bug
that needs to be fixed, so please don't try to take any more things in that
direction.

On Mon, Oct 21, 2019, 10:02 AM Isaac Freund notifications@github.com
wrote:

So, ACT_MOVE_ITEMS will actually already adjust the moves it consumes
based on the distance each item is moved
https://github.com/CleverRaven/Cataclysm-DDA/blob/7787bc041afa43883ee41bc38e70988c5d5e2d08/src/activity_item_handling.cpp#L756
This comes into play when, for example, using the advanced inventory to
move an item 2 tiles at a time instead of just one.

What needs to happen to implement is most likely the creation of a new
activity,ACT_HAUL_TO_TARGET or something of the sort, which allows the
player to select a destination and automatically moves all items at the
player's feet to the destination, moving each item in the largest jumps
possible without taking the player below 0 moves.

There is however a potential exploit in this kind of abstraction, since
the player could then for example "haul" a grenade or other item out into a
group of zombies without the game ever simulating the player moving from
their tile. This is already technically possible to do with zone sorting by
the way though and It's unclear to me what the best solution would be.

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/CleverRaven/Cataclysm-DDA/issues/34918?email_source=notifications&email_token=AAGSA5GML4NHQ7QF2LCQ6JTQPXOC5A5CNFSM4JC5XJVKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEB3BSBI#issuecomment-544610565,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAGSA5F3N2YKIC4NVW52J63QPXOC5ANCNFSM4JC5XJVA
.

That's totally fair. Unfortunately it seems there isn't too much that can be optimized within the hauling activity as a quick profile shows that game::process_activity() takes only 31.6% of main() and 89.5% of game::process_activity() is involved in allocating and freeing memory for the items moved one step at a time.

Optimization time would most likely be better spend optimizing either scent_map() or mon_move(). Also of note, I saw game::autopilot_vehicles() showing up at 4.4% of main() despite no auto piloting being active afaik.

I tested by hauling 1000 rags across the ground.

Totally fair. If there is no optimization to be had in the hauling code, we need to look at other optimizations.

Maybe we just need to get more creative. If we created a new temporary data structure to hold the items while hauling we could avoid all the reallocations. That would lead to a fairly significant speedup but require significantly different code from what we have now.

Another direction to take it is to replace hauling with "move items to
destination" and actually pick items up to capacity, walk to the
destination, drop items, and return.

On Mon, Oct 21, 2019, 12:02 PM Isaac Freund notifications@github.com
wrote:

Maybe we just need to get more creative. If we created a new temporary
data structure to hold the items while hauling we could avoid all the
reallocations. That would lead to a fairly significant speedup but require
significantly different code from what we have now.

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/CleverRaven/Cataclysm-DDA/issues/34918?email_source=notifications&email_token=AAGSA5GZFZUQGFZHT43RKJLQPX4EPA5CNFSM4JC5XJVKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEB3NQUI#issuecomment-544659537,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAGSA5FDW74TTTKCS6CSD2DQPX4EPANCNFSM4JC5XJVA
.

I'm not against that at all, though I'm a bit worried about big and heavy objects (large liquid containers, for instance). Being able to haul tile by tile is very important too - especially across z levels. Maybe both can be combined.

We could fall back to hauling for things too big to carry, but that's also
not going to be thousands of item insertions and removals per turn.

On Mon, Oct 21, 2019, 9:02 PM Tivec notifications@github.com wrote:

I'm not against that at all, though I'm a bit worried about big and heavy
objects (large liquid containers, for instance). Being able to haul tile by
tile is very important too - especially across z levels. Maybe both can be
combined.

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/CleverRaven/Cataclysm-DDA/issues/34918?email_source=notifications&email_token=AAGSA5GJP2LDZ6FFWD2DTI3QPZ3NFA5CNFSM4JC5XJVKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEB4PAQY#issuecomment-544796739,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAGSA5CZTF7J5BROR3L2DD3QPZ3NFANCNFSM4JC5XJVA
.

Where hauling is indispensable is for single items that are so heavy that you will injure yourself carrying them, rapidly run out of stamina, or just not be able to move.

Where it is merely handy is when you have a whole crap load of stuff that you just don't want to have to make a bunch of trips for. I understand that someone is working on making containers like backpacks / sacks / etc. actually do something more than increase carrying volume capacity (e.g. actually 'contain' items). If you're hauling four sacks full of junk would that be more efficient than hauling 500 different items? Conceptually speaking 'hauling' a huge number of small items doesn't really make much sense - unless you are using a broom to sweep along a pile of leaves or something. Maybe you could work with the container code and limit hauling to a handful or so objects at a time (but include containers of other objects).

I think that wathever solution is implemented there are three things that should be taken in consideration : performance, "realism" for the caracter and conveniance for the player. I mean clearing out a lab should be a time consuming task for the caracter not for the player. Actually cleary out a medium lab to take everything back to the surface take a full day for my character using drag and only 10 to 15 minute for me (once there is no more enemies in the lab). This should'nt take more time from the player perspective. Before the implementation of dragging it was a plain chore for the player to do, and a game should'nt be a chore from the player perspective or at least it should be reduced every time it's possible.

So please take player conveniance in consideration when discussing such issues. :-)

That's just my own thougt.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. Please do not \'bump\' or comment on this issue unless you are actively working on it. Stale issues, and stale issues that are closed are still considered.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. Please do not \'bump\' or comment on this issue unless you are actively working on it. Stale issues, and stale issues that are closed are still considered.

Can somebody please confirm that this is still an issue?

Profiling shows that item hauling takes approximately same time as rendering and is on the same magnitude as Character::update_bodytemp(), which is to say pretty low.

image

Note, item hauling is connected to the general game simulation speed, as it take a significant amount of in-game time, consequently it might be slower in the places like labs and refugee centers.

Was this page helpful?
0 / 5 - 0 ratings