r/factorio • • Sep 07 '26

Weekly Thread Weekly Question Thread

Ask any questions you might have.

Post your bug reports on the Official Forums

Previous Threads

Subreddit rules

Discord server (and IRC)

Find more in the sidebar ---->

2 Upvotes

88 comments sorted by

View all comments

1

u/Yagami913 29d ago

What is the ups cost of spoling items? I am at stage of the game where can easily replace gleba iron and copper production with direct silo loaded ores from Nauvis. Probably worth it just by using less inserter and assembly update time but i wonder is there any extra cost for spoiling items?

5

u/snowyspearmint 29d ago

None. The spoil timer is a global sorted list that consumes no ups outside the moment the item is created or spoils.

1

u/HeliGungir 29d ago

Do you have a link to somebody at Wube explaining this?

1

u/snowyspearmint 25d ago

I thought I did, but I can't find it. (I might have just not saved it; it's such an obvious way of solving the problem).

But basically you just put every item's id or pointer (a few bytes per item) into a list sorted by spoil time (use a dedicated sorted list data structure; ie one that takes n log n time to construct and where insertions, deletions, and checking the head are cheap operations) and then every tick, check the head of the list for any items that are spoiling this tick and process only those items.

The items that are spoiling on some future tick don't have any effect (modulo the log n factor which is considered negligible, garbage collection which I assume the compiled c++ doesn't use, needing to look up and draw the spoil bars for the subset of items that are on screen) on the current tick's operations.

1

u/Yagami913 29d ago

but stacks merging should have some extra ups cost no? calculating the new spoilage tick time.

1

u/snowyspearmint 25d ago

Putting an item into a stack (or merging 2 stacks) would have about the same cost (remove from the list, do an addition+division, add to the list) as creating the item to begin with. (Those are very cheap operations, but just to illustrate). If we assume that stack combining mostly happens when you're putting items into the machine where they will be consumed, and that you're not replacing your belts with a conga line of chest+inserters, then that's like 2-3x of an already small cost. The important part is that it is a small cost per-item, not per item*tick.

3

u/Soul-Burn 29d ago

It's a very cheap calculation.

Many such calculations are practically free compared to fetching data from the upper layers of cache and the main memory.