Page 1 of 1

Multiple outputs from factory. Inserters priority question.

Posted: Mon Jun 19, 2017 9:11 pm
by Hooch
Hell.
Quick question.

If there is factory with multiply output inserters. What is the mechanism those inserters use to take out from factory. Do they took equal share or is it random?

Re: Multiple outputs from factory. Inserters priority question.

Posted: Mon Jun 19, 2017 9:25 pm
by impetus maximus
setting up an assembler to make gears it cycled the output inserters South, West, East, and North.
it repeated the same order every 4 gears.

Re: Multiple outputs from factory. Inserters priority question.

Posted: Mon Jun 19, 2017 9:27 pm
by Hooch
So it ensures that output goes equally to all inserters. Great.

Re: Multiple outputs from factory. Inserters priority question.

Posted: Mon Jun 19, 2017 10:04 pm
by Tym
following up; if there are different -speed- inserters attached to an assembler, do the faster inserts get served before the slower ones? assume yellow and blue inserters.

Re: Multiple outputs from factory. Inserters priority question.

Posted: Mon Jun 19, 2017 11:42 pm
by impetus maximus
Tym wrote:following up; if there are different -speed- inserters attached to an assembler, do the faster inserts get served before the slower ones? assume yellow and blue inserters.
there will be a bias towards the faster inserter, but it still seems to share with the slower ones. tested in 0.15.21 with 'Creative Mode', and 'Nixie Tubes' mods.
[edit] the bias only happened when the output was faster than the standard inserters could keep up with. with a lvl 1 making gears it was 1:1:1:1
with a lvl 2 assembler the fast inserter output more gears than a standard one. [/edit]
screenshot

Re: Multiple outputs from factory. Inserters priority question.

Posted: Tue Jun 20, 2017 2:20 pm
by torne
My guess would be that each inserter checks if there is anything to remove from the factory, and if not, adds itself to a wakeup queue associated with the factory. This just happens to give balanced behaviour with multiple same-speed inserters: they will probably start off cycling in the order they were built (since the first one to be built added itself to the queue first), and since they all take the same time to cycle back to their starting position, they will always reinsert themselves into the queue in the same sequence. If the inserters aren't the same speed, the faster ones might "jump the queue" ahead of a slower inserter which is still in the process of swinging.

If that's how it works (which seems likely to me given the observed behaviour and past dev comments about wakeup queues in the engine) then it's guaranteed that each inserter will get *some* amount of product (none will be completely starved) but you aren't guaranteed to get an even split in all cases even if the inserters are the same speed: for example if the inserters have a stack size of 2 and the factory produces 3 items in the time it takes the inserters to cycle once, then one of the inserters will always pick up 2 items and the other will always pick up 1, leading to unbalanced output.

Re: Multiple outputs from factory. Inserters priority question.

Posted: Tue Jun 20, 2017 2:23 pm
by torne
Hm, actually, it might not be starvation-free: it depends on the order of evaluation. It might be possible for an inserter that returns to its starting position on the exact same tick that the factory produces an item to "jump the queue" if that happens to be processed before the wakeups happen, because I don't think machines go into the queue if their inputs are already available (as that would be wasteful). That seems like a tricky experiment to set up..

Re: Multiple outputs from factory. Inserters priority question.

Posted: Tue Jun 20, 2017 2:43 pm
by Ranakastrasz
Really? When did this get added. I've been irritated since i started having multiple output directions that one inserter hogs the entire output till it backs up.

Gotta re-test this.