[boskid][2.0.20] Read full belt content on very long belt loop halts the game when the belt is cut

This subforum contains all the issues which we already resolved.
yuu6883dev
Burner Inserter
Burner Inserter
Posts: 5
Joined: Sat Nov 09, 2024 4:26 am
Contact:

[boskid][2.0.20] Read full belt content on very long belt loop halts the game when the belt is cut

Post by yuu6883dev »

A very long belt for storing some rocks:
image (37).jpg
image (37).jpg (675.47 KiB) Viewed 1108 times
Top left I'm reading belt content
Delete any section of the belt and the game halts (probably infinite loop)
No crash log / nothing abnormal in game log / no output after halt
100% reproducible on my side (tried at least 5 times)
Blueprint of entire ship is attached (belt.txt), don't think the save file has any use.
Issue is not seen when I'm not reading full belt content and cutting the belt
Attachments
belt.txt
(451.32 KiB) Downloaded 13 times
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 3078
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: [2.0.20] Read full belt content on very long belt loop halts the game when the belt is cut

Post by boskid »

Its not infinite loop, it looks like it is O(N^2) where N is amount of belt belt pieces: when removing 1 belt piece there is code that tries to span transport line nicely, but before doing so it cuts the entire sequence into 1 tile long pieces (this is the first N) and when every piece is created, belt reader is propagated backward and forward (this is the second N). I may have some ideas how to improve this slightly, but this really feels like one of the "stop shooting yourself into your foot from the artillery cannot" case.
yuu6883dev
Burner Inserter
Burner Inserter
Posts: 5
Joined: Sat Nov 09, 2024 4:26 am
Contact:

Re: [boskid][2.0.20] Read full belt content on very long belt loop halts the game when the belt is cut

Post by yuu6883dev »

hmm, can the belt reader be propagated after the new lines are formed? It would still be O(N).
By any means, this is a really niche situation that I can work around.
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 3078
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: [boskid][2.0.20] Read full belt content on very long belt loop halts the game when the belt is cut

Post by boskid »

Ok, it looks like by adding a strategic one line of code in one specifc place fixes this issue completly without even need to rewrite the remerge logic. So this issue should be now fixed for 2.0.22.
yuu6883dev
Burner Inserter
Burner Inserter
Posts: 5
Joined: Sat Nov 09, 2024 4:26 am
Contact:

Re: [boskid][2.0.20] Read full belt content on very long belt loop halts the game when the belt is cut

Post by yuu6883dev »

Thanks for the quick fix!
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 3078
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: [boskid][2.0.20] Read full belt content on very long belt loop halts the game when the belt is cut

Post by boskid »

Ok, i did also another optimization on top of the previous one, a rewirite of the remerge logic and now my setup that consists of 250k of transport belts connected in sequence with belt reader active, when removing a belt takes about 8ms for the remerge operation which is hardly noticable. In 2.0.21 that same setup was taking way more than 5 minutes (i never saw it finish) so i am going to call it a success.
Post Reply

Return to “Resolved Problems and Bugs”