Reached id limit for quality

Place to post guides, observations, things related to modding that are not mods themselves.
Chaos234
Long Handed Inserter
Long Handed Inserter
Posts: 56
Joined: Sat Jun 27, 2015 10:45 pm
Contact:

Reached id limit for quality

Post by Chaos234 »

As you can see in the picture below I can not understand why even in Factorio 2.0 (Space Age) an engine hardcoded ID Limit for quality is used. Sorry but even Mojang managed to remove such a limiting system but has had way more IDs allowed then Factorio 2.x with only 255 possible instances for quality ids.

Error from the client (modded):
08-26-2025, 18-07-08.png
08-26-2025, 18-07-08.png (37.42 KiB) Viewed 348 times
This makes it impossible to use in some Modpacks licke Stellar Horizons to use the mod https://mods.factorio.com/mod/infinite-quality-tiers since this mod does exactly what it stand for -> Creating infinite Qualities since we should not be limited here at this point.

Well sure, the used engine in the background could have some problems but then it's up to the user who has gone far beyond the regular "limits".

So at last I request a full limit lift an converting it into an adjustable option just for safety and a 2nd option to disable this limit with a red warning, that this could cause engine problems (early on or later on).

In a second step I am asking me why IDs after alla re used instead of getting eliminated here? It should be much better to just use unlocalized names as UIDs here which can not exist twice (but can be overwritten by mods or entirely replaced) which would eliminate the need of an ID here. Since it is hardcoded within the used engine there is no way to help from outside of this with a test rewrite of the affected code within the engine so it's up to you Wube, to catch up on this medium one.

It would help everybody at the end and I would appreciate to see this coming up :)
eugenekay
Filter Inserter
Filter Inserter
Posts: 686
Joined: Tue May 15, 2018 2:14 am
Contact:

Re: Reached id limit for quality

Post by eugenekay »

Chaos234 wrote: Tue Aug 26, 2025 4:19 pmAs you can see in the picture below I can not understand why even in Factorio 2.0 (Space Age) an engine hardcoded ID Limit for quality is used. Sorry but even Mojang managed to remove such a limiting system but has had way more IDs allowed then Factorio 2.x with only 255 possible instances for quality ids.

Every programming choice is a tradeoff. 255 levels (plus the "Null state") is representable in-memory by a single Byte (8 bits = 2^8 = 256). This data must be stored for each and every entity in the game; and you need to reserve this space even if the entity does not have Quality currently. Extending this to 2 bytes (2^16 = 65,536) would potentially increase Memory usage for every player of the game, and lead to a degraded user experience, particularly on memory-limited platforms like the Nintendo Switch.

Other games use a different Data structure which allows for free-form "tags" attached to individual entities that can expand/contract. Due to the differences in the consistency model their engines are not doing as much iteration over every object every physics tick so this does not bring a comparable decrease in performance. IE: they are "Optimizing for performance" at the expense of accuracy or lag time before actions are processed.

The base game has only 5 active levels of Quality. 255 possible levels seems like a good "Maximum" given the constraints.

Good Luck!
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 4117
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: Reached id limit for quality

Post by boskid »

We have no interest in allowing more than 255 qualities. Given that items have quality, if the variable holding quality of items would be 2 bytes that already messes up alignment of all inventories and would increase memory from 24 bytes per item stack to 32 bytes per item stack. Multiple other places were optimized assuming quality is 1 byte (for example circuit network) and we wont drop those changes just because someone wants to define arbitrary amount of qualities.
Shirasik
Long Handed Inserter
Long Handed Inserter
Posts: 55
Joined: Mon Apr 28, 2025 12:17 pm
Contact:

Re: Reached id limit for quality

Post by Shirasik »

boskid wrote: Tue Aug 26, 2025 6:14 pm We have no interest in allowing more than 255 qualities. Given that items have quality, if the variable holding quality of items would be 2 bytes that already messes up alignment of all inventories and would increase memory from 24 bytes per item stack to 32 bytes per item stack.
So you will move from 3 words to 4 words (Factorio is 64bit app). How this breaks alignment? Or you have "harddesigned" cache line alignment optimisations? Just curious.
computeraddict
Filter Inserter
Filter Inserter
Posts: 379
Joined: Sat Oct 07, 2023 6:44 am
Contact:

Re: Reached id limit for quality

Post by computeraddict »

Shirasik wrote: Tue Aug 26, 2025 6:54 pm Or you have "harddesigned" cache line alignment optimisations?
It's generally safe to assume that the Factorio devs have done the most aggressive optimization possible
Chaos234
Long Handed Inserter
Long Handed Inserter
Posts: 56
Joined: Sat Jun 27, 2015 10:45 pm
Contact:

Re: Reached id limit for quality

Post by Chaos234 »

computeraddict wrote: Tue Aug 26, 2025 7:15 pm
Shirasik wrote: Tue Aug 26, 2025 6:54 pm Or you have "harddesigned" cache line alignment optimisations?
It's generally safe to assume that the Factorio devs have done the most aggressive optimization possible
Not only that, since this game runs on multiple platforms and yes, the switch (2) is not a machine like a PC where you can just open the cover and insert more RAM so the stated calculations from the first response to my initial post makes sense to keep it at 255 at this point even if a higher number would be appreciated though.

At this point we need to make compromises in terms of optimization or not. Not even I was aware that this was related to to the 1 byte limit which is then needed for really everything so it makes sense to not go higher even if modern PCs would have that potential piece of memory the switch f. e. wouldn't.

Maybe there is a solution in the future still so we'll have to wait :)
Post Reply

Return to “Modding discussion”