Inserter/chest Optimization idea

Post your ideas and suggestions how to improve the game.

Moderator: ickputzdirwech

McFrugal
Burner Inserter
Burner Inserter
Posts: 11
Joined: Tue Apr 26, 2022 3:04 pm
Contact:

Inserter/chest Optimization idea

Post by McFrugal »

The problem right now is when an inserter wants to insert or remove an item, it has to check each slot until it finds a valid one, right? What if the chest inventory was split into three arrays- full slots, empty slots, and partially filled slots?
It works like this:
When an item needs to be inserted, it can check the list of partially filled slots first, which will be much smaller than the other two lists. If it can't fit the item type in, then it goes to the first slot in the empty slot list.
When an item needs to be taken out, it can check the list of partially filled slots first, then the list of filled slots. This can be expensive since it needs to iterate on the list of filled slots and that can potentially be large, but after it does so the item removed causes that slot to be a partial slot, which means the next removal is much faster.

Doing it this way means in most cases, the inserter only has to look at a list of 10 or less slots.

There is a side effect that if there are empty slots near the top of the container they won't be filled until partially filled slots are filled up. I don't think that will break any automation though.
FuryoftheStars
Smart Inserter
Smart Inserter
Posts: 2768
Joined: Tue Apr 25, 2017 2:01 pm
Contact:

Re: Inserter/chest Optimization idea

Post by FuryoftheStars »

There have already been multiple threads on this, some of which have dev answers.
My Mods: Classic Factorio Basic Oil Processing | Sulfur Production from Oils | Wood to Oil Processing | Infinite Resources - Normal Yield | Tree Saplings (Redux) | Alien Biomes Tweaked | Restrictions on Artificial Tiles | New Gear Girl & HR Graphics
McFrugal
Burner Inserter
Burner Inserter
Posts: 11
Joined: Tue Apr 26, 2022 3:04 pm
Contact:

Re: Inserter/chest Optimization idea

Post by McFrugal »

Yes, I did some searches and didn't see any ideas similar to mine.
User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12889
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: Inserter/chest Optimization idea

Post by ssilk »

McFrugal, you forget the general use case of chests which your suggestion will make slower.

Optimizing suggestions need to think much, much deeper than the part you want to optimize, because the problem is highly complex: with your changes you change not only the problem, but also every other aspect of chests etc. and you need to think them all through, because you don’t have the code to just test it out like the devs can.

And it’s not so that this suggestion is not good. Everything fine with it, it just needs much more thinking and discussion around it; maybe we find a solution, maybe not.
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...
Rseding91
Factorio Staff
Factorio Staff
Posts: 14269
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Inserter/chest Optimization idea

Post by Rseding91 »

Unless in modded land with 1000+ slot chests the 'scan the inventory' logic base game uses is not slow. It never shows up in profiling results for save files.
If you want to get ahold of me I'm almost always on Discord.
FuryoftheStars
Smart Inserter
Smart Inserter
Posts: 2768
Joined: Tue Apr 25, 2017 2:01 pm
Contact:

Re: Inserter/chest Optimization idea

Post by FuryoftheStars »

McFrugal wrote: Sat Jul 16, 2022 4:59 am Yes, I did some searches and didn't see any ideas similar to mine.
Well, the generic titles kind of lend themselves to open discussions, I feel, vs everyone posting their own different idea into different threads for the same topic.

But that wasn’t the main point/issue.

This was:
Rseding91 wrote: Sat Jul 16, 2022 1:53 pm Unless in modded land with 1000+ slot chests the 'scan the inventory' logic base game uses is not slow. It never shows up in profiling results for save files.
And they (the devs) have said this before in those threads I was referring to. That was my point.
My Mods: Classic Factorio Basic Oil Processing | Sulfur Production from Oils | Wood to Oil Processing | Infinite Resources - Normal Yield | Tree Saplings (Redux) | Alien Biomes Tweaked | Restrictions on Artificial Tiles | New Gear Girl & HR Graphics
Post Reply

Return to “Ideas and Suggestions”