Use 64-bit integers for signals

Post your ideas and suggestions how to improve the game.

Moderator: ickputzdirwech

lightdark
Burner Inserter
Burner Inserter
Posts: 14
Joined: Mon Mar 25, 2019 6:02 am
Contact:

Use 64-bit integers for signals

Post by lightdark »

Right now, the circuit network uses 32-bit integers for signals. If you're counting items, this is more than plenty, but the limit of ~4 billion can be a bit limiting when measuring other values, e.g. energy.

Right now, I'd like to be able to set a circuit signal to measure energy in J, but because of the ~4G limit, this isn't very practical, and I instead have to measure in kJ. If there were 64-bit signals, this wouldn't be an issue, as the limit would be raised to ~18E.

I can't imagine this causing any noticeable performance cut, even on 32-bit systems. If people are relying on integer overflow I think it's reasonable to expect people to use an arithmetic combinator to chop off the extra bits. Honestly, I'd personally prefer that signals saturated (e.g. stay at the maximum) rather than overflowing, but it doesn't matter too much.
BHakluyt
Filter Inserter
Filter Inserter
Posts: 262
Joined: Sat Oct 08, 2016 12:43 pm
Contact:

Re: Use 64-bit integers for signals

Post by BHakluyt »

lightdark wrote: Sun Oct 20, 2019 3:32 am can't imagine this causing any noticeable performance cut, even on 32-bit systems. If people are relying on integer overflow I think it's reasonable to expect people to use an arithmetic combinator to chop off the extra bits. Honestly, I'd personally prefer that signals saturated (e.g. stay at the maximum) rather than overflowing, but it doesn't matter too much.
If I can have displays that count every copper wire produced in my megabase which goes into the billions I am all for it! It's always been feeling like a waste to count stuff if the limit the game can count on a combinator is so limited...
User avatar
BlueTemplar
Smart Inserter
Smart Inserter
Posts: 3110
Joined: Fri Jun 08, 2018 2:16 pm
Contact:

Re: Use 64-bit integers for signals

Post by BlueTemplar »

Factorio has dropped support for 32-bit systems with 0.14/0.15 :
https://factorio.com/blog/post/fff-158
BobDiggity (mod-scenario-pack)
kbk
Long Handed Inserter
Long Handed Inserter
Posts: 58
Joined: Sun Jun 30, 2019 2:21 pm
Contact:

Re: Use 64-bit integers for signals

Post by kbk »

BlueTemplar wrote: Sun Oct 20, 2019 12:28 pm Factorio has dropped support for 32-bit systems with 0.14/0.15 :
https://factorio.com/blog/post/fff-158
OP is clearly talking about switching from uint32 to uint64 integer variables in terms of signal value storage, not about memory adressing and hardware architecture issues. I mean, you definitely can store a quad in a 32bit app.
Last edited by kbk on Sun Oct 20, 2019 1:22 pm, edited 1 time in total.
User avatar
BlueTemplar
Smart Inserter
Smart Inserter
Posts: 3110
Joined: Fri Jun 08, 2018 2:16 pm
Contact:

Re: Use 64-bit integers for signals

Post by BlueTemplar »

What else could he mean with "32-bit systems" ?
P.S.: My point is that performance worries on 32-bit systems aren't relevant.
BobDiggity (mod-scenario-pack)
kbk
Long Handed Inserter
Long Handed Inserter
Posts: 58
Joined: Sun Jun 30, 2019 2:21 pm
Contact:

Re: Use 64-bit integers for signals

Post by kbk »

BlueTemplar wrote: Sun Oct 20, 2019 1:20 pm What else could he mean with "32-bit systems" ?
P.S.: My point is that performance worries on 32-bit systems aren't relevant.
Yep, took me too long to edit previous post, sorry. OPs suggestions about 32bit applications just were met by a technically correct but quirky response I became too tempted to clarify, that's all :D
coppercoil
Filter Inserter
Filter Inserter
Posts: 502
Joined: Tue Jun 26, 2018 10:14 am
Contact:

Re: Use 64-bit integers for signals

Post by coppercoil »

I want 64b arithmetic too. My numbers are not so big, but I use various mathematical formulas and sometimes there are large intermediate results inside.
lightdark
Burner Inserter
Burner Inserter
Posts: 14
Joined: Mon Mar 25, 2019 6:02 am
Contact:

Re: Use 64-bit integers for signals

Post by lightdark »

kbk wrote: Sun Oct 20, 2019 1:19 pm
BlueTemplar wrote: Sun Oct 20, 2019 12:28 pm Factorio has dropped support for 32-bit systems with 0.14/0.15 :
https://factorio.com/blog/post/fff-158
OP is clearly talking about switching from uint32 to uint64 integer variables in terms of signal value storage, not about memory adressing and hardware architecture issues. I mean, you definitely can store a quad in a 32bit app.
Yup! Having to use double the space to store every signal could definitely cause performance issues.
BlueTemplar wrote: Sun Oct 20, 2019 1:20 pm What else could he mean with "32-bit systems" ?
P.S.: My point is that performance worries on 32-bit systems aren't relevant.
P.S.: I'm not a guy; note that the others used "OP" to refer to me instead of "he."
AlexAegis
Inserter
Inserter
Posts: 41
Joined: Sat Jun 04, 2016 10:25 pm
Contact:

Re: Use 64-bit integers for signals

Post by AlexAegis »

lightdark wrote: Sun Nov 10, 2019 10:23 pm
kbk wrote: Sun Oct 20, 2019 1:19 pm
BlueTemplar wrote: Sun Oct 20, 2019 12:28 pm Factorio has dropped support for 32-bit systems with 0.14/0.15 :
https://factorio.com/blog/post/fff-158
OP is clearly talking about switching from uint32 to uint64 integer variables in terms of signal value storage, not about memory adressing and hardware architecture issues. I mean, you definitely can store a quad in a 32bit app.
Yup! Having to use double the space to store every signal could definitely cause performance issues.
BlueTemplar wrote: Sun Oct 20, 2019 1:20 pm What else could he mean with "32-bit systems" ?
P.S.: My point is that performance worries on 32-bit systems aren't relevant.
P.S.: I'm not a guy; note that the others used "OP" to refer to me instead of "he."
According to this post from 2011: https://www.passmark.com/forum/performa ... -maths-pt8

Image

There's no performance impact, except for division, but then again, it's from 2011, it's migth be better.

The larger memory footprint should be an issue though.
mrvn
Smart Inserter
Smart Inserter
Posts: 5865
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Use 64-bit integers for signals

Post by mrvn »

Unless I'm mistaken the LUA interpreter uses double for everything. That means 64bit signals would not be fully usable from mods. You would only get 56 bit precision iirc. I think that's a show stopper.

Also every setup that uses the integer overflow hack would break when you switch to 64bit signals. Although they could switch to the new constant to overflow at 64bit. A migration script could even change every constant close to 2G to their 64bit equivalent.
User avatar
BlueTemplar
Smart Inserter
Smart Inserter
Posts: 3110
Joined: Fri Jun 08, 2018 2:16 pm
Contact:

Re: Use 64-bit integers for signals

Post by BlueTemplar »

LUA interpreter doesn't have integer support ?!?
lightdark wrote: Sun Nov 10, 2019 10:23 pm P.S.: I'm not a guy; note that the others used "OP" to refer to me instead of "he."
My bad.
BobDiggity (mod-scenario-pack)
User avatar
Impatient
Filter Inserter
Filter Inserter
Posts: 883
Joined: Sun Mar 20, 2016 2:51 am
Contact:

Allow integer values up to the 64 bit boundaries in the circuit network

Post by Impatient »

TL;DR
Allow integer values up to the 64 bit boundaries in the circuit network
What ?
As the 32 bit support was dropped (I read somewhere) allow integer values of up to the 64 bit boundaries in the circuit network.
Why ?
This would allow for calculations which need big numbers.
User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2920
Joined: Sat Jun 11, 2016 6:41 am
Contact:

Re: Allow integer values up to the 64 bit boundaries in the circuit network

Post by Optera »

Where did you read that?

Changing circuit network from 32 signed to 64 signed would break all designs making use of integer overflow. Not world ending, but the argument of not wanting to break existing circuit designs has been used for years to defend mathematical correct fluid rounding.
User avatar
Impatient
Filter Inserter
Filter Inserter
Posts: 883
Joined: Sun Mar 20, 2016 2:51 am
Contact:

Re: Allow integer values up to the 64 bit boundaries in the circuit network

Post by Impatient »

You are right on that one.

Where I read that? It is in lot of places:
viewtopic.php?t=72195
User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2920
Joined: Sat Jun 11, 2016 6:41 am
Contact:

Re: Allow integer values up to the 64 bit boundaries in the circuit network

Post by Optera »

Just because Factorio is no longer compiled for 32bit systems doesn't mean it uses 64bit data types throughout.
Factorio still uses Lua 5.2, 64bit types where introduced in Lua 5.3.
http://www.lua.org/manual/5.2/manual.html#2.1
http://www.lua.org/manual/5.3/manual.html#2.1

Edit: It is possible Factorios Lua implementation already uses 64bit.
User avatar
BlueTemplar
Smart Inserter
Smart Inserter
Posts: 3110
Joined: Fri Jun 08, 2018 2:16 pm
Contact:

Re: Allow integer values up to the 64 bit boundaries in the circuit network

Post by BlueTemplar »

duplicate : 77006
BobDiggity (mod-scenario-pack)
User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12889
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: Use 64-bit integers for signals

Post by ssilk »

Merged, thanks to BlueTemplar
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...
coppercoil
Filter Inserter
Filter Inserter
Posts: 502
Joined: Tue Jun 26, 2018 10:14 am
Contact:

Re: Use 64-bit integers for signals

Post by coppercoil »

A second tier of circuit items could be added to not break existing 32b hacks. There also can be different networks for 32b and 64b signals if they really cannot be mixed. Floating point calculations could be also considered. Why not? It's not a rocket science.
Last edited by coppercoil on Mon Feb 03, 2020 12:18 pm, edited 1 time in total.
mrvn
Smart Inserter
Smart Inserter
Posts: 5865
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Use 64-bit integers for signals

Post by mrvn »

Or it could be 56 bit signals so they still fit in a double.
Sopel
Long Handed Inserter
Long Handed Inserter
Posts: 72
Joined: Mon Sep 24, 2018 8:30 pm
Contact:

Re: Use 64-bit integers for signals

Post by Sopel »

"There's no performance impact, except for division, but then again, it's from 2011, it's migth be better."
This is a microbenchmark. When you take cache into consideration it has an impact.
Though the whole system is complex and such a little change would likely not matter in the end.

"A second tier of circuit items could be added to not break existing 32b hacks."
The problem is that signals are stored the same regardless of the entity type. This would only increase implementation complexity.

"Or it could be 56 bit signals so they still fit in a double."
Lua DOES have integer types
Post Reply

Return to “Ideas and Suggestions”