Page 1 of 2

Use 64-bit integers for signals

Posted: Sun Oct 20, 2019 3:32 am
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.

Re: Use 64-bit integers for signals

Posted: Sun Oct 20, 2019 11:40 am
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...

Re: Use 64-bit integers for signals

Posted: Sun Oct 20, 2019 12:28 pm
by BlueTemplar
Factorio has dropped support for 32-bit systems with 0.14/0.15 :
https://factorio.com/blog/post/fff-158

Re: Use 64-bit integers for signals

Posted: Sun Oct 20, 2019 1:19 pm
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.

Re: Use 64-bit integers for signals

Posted: Sun Oct 20, 2019 1:20 pm
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.

Re: Use 64-bit integers for signals

Posted: Sun Oct 20, 2019 1:30 pm
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

Re: Use 64-bit integers for signals

Posted: Sun Oct 20, 2019 1:56 pm
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.

Re: Use 64-bit integers for signals

Posted: Sun Nov 10, 2019 10:23 pm
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."

Re: Use 64-bit integers for signals

Posted: Mon Nov 11, 2019 11:14 am
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.

Re: Use 64-bit integers for signals

Posted: Mon Nov 11, 2019 12:12 pm
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.

Re: Use 64-bit integers for signals

Posted: Sat Dec 07, 2019 3:09 pm
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.

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

Posted: Sun Feb 02, 2020 5:50 am
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.

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

Posted: Sun Feb 02, 2020 8:15 am
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.

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

Posted: Sun Feb 02, 2020 9:12 am
by Impatient
You are right on that one.

Where I read that? It is in lot of places:
viewtopic.php?t=72195

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

Posted: Sun Feb 02, 2020 10:32 am
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.

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

Posted: Sun Feb 02, 2020 10:41 am
by BlueTemplar
duplicate : 77006

Re: Use 64-bit integers for signals

Posted: Mon Feb 03, 2020 7:27 am
by ssilk
Merged, thanks to BlueTemplar

Re: Use 64-bit integers for signals

Posted: Mon Feb 03, 2020 9:20 am
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.

Re: Use 64-bit integers for signals

Posted: Mon Feb 03, 2020 10:09 am
by mrvn
Or it could be 56 bit signals so they still fit in a double.

Re: Use 64-bit integers for signals

Posted: Tue Feb 04, 2020 12:35 pm
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