4 ms·
Can't we fix this once and for all using variable length integers? https://en.wikipedia.org/wiki/Variable-length_quantity https://en.wikipedia.org/wiki/Variabl
by matheusmoreira 3y ago
Can't we fix this once and for all using variable length integers?
https://en.wikipedia.org/wiki/Variable-length_quantity https://en.wikipedia.org/wiki/Variable-length_quantity
This way the counter can scale up to any number of bits.
- School-Cotton 3y agoIt is already fixed once and for all by using i64, unless you care about dates hundreds of billions of years in the future or past.
- matheusmoreira 3y agoOr unless you use more precise clocks. Nanosecond resolution cuts those billions down to hundreds of years. We're probably gonna get picosecond or femtosecond resolution clocks someday. Then we're gonna have yet another one of these threads and someone's gonna tell me 128 bits will fix it forever.
- School-Cotton 3y agoThose are already different types, though. What type it makes sense to use for seconds isn’t necessarily the same as what type it makes sense to use for other time units. I agree that using 128 bits makes sense for nanoseconds if for some reason you care about nanosecond-precision timestamps merely hundreds of years in the future or past. I find it hard to believe we will ever have femtoseconds-resolution timers or ever even care what femtosecond an event happened at. But even if we do, incidentally, 128 bits is still fine. i128 femtoseconds will overflow in approximately the year 1000000000000000000000000. So, I don’t think there’s any practically useful time unit for which we need variable length integers and can’t just use i128.
- matheusmoreira 3y ago> I find it hard to believe we will ever [...] care what femtosecond an event happened at GNSS satellites require precise clocks to accurately calculate ranges. Signals travel at the speed of light so small imprecisions result in large errors: timing differences of one millisecond produce about 300 kilometers of error in distance measurements. It seems GPS satellites have clocks accurate to within 40 nanoseconds. One nanosecond gives around 30 cm of error, 40 nanoseconds would give about 12 meters. Picosecond resolution would bring those errors down to the millimeter and micrometer ranges. Femtosecond resolution would bring the errors down to nanometers.
- School-Cotton 3y agoOkay, fair enough. But i128 is still plenty for femtoseconds. Keep in mind that going from 64 to 128 bits squares the available range. The number of femtoseconds is merely a million times the number of nanoseconds, whereas the number of numbers representable by an i128 is 2^64 times the number representable by an i64.
- Dylan16807 3y ago> Picosecond resolution would bring those errors down to the millimeter and micrometer ranges. Femtosecond resolution would bring the errors down to nanometers. And nobody can measure the signal that precisely.
- matheusmoreira 3y agoI'm not knowledgeable enough about signals to know whether it's impossible or not. Maybe it's not possible now but one day it will be.
- randyrand 3y agoThat would add a lot of complexity to structs that want to have a static size. i’d just pick a huge number and move on.
- paulddraper 3y agoThat's unnecessarily complicated. A 64-bit signed Unix time fixes this for 25x longer than the remaining lifetime of the sun.
- Kamq 3y agoOur descendants around alpha centauri are going to have so much legacy code to upgrade.
- maxerickson 3y agoEver read A Deepness in the Sky?
- paulddraper 3y agoWow that brings back memories
- nly 3y agoUnless you want to keep time to nanosecond granularity, like in a typical modern trading system. Then you have only +/- 292 years.
- matheusmoreira 3y agoWhat if we have picosecond precision timers in the future? Femtosecond precision timers? Who knows, right?
- paulddraper 3y agoTrue, but here we're taking about Unix time, which is seconds since 1970 UTC. AFAIK, most systems with absolute nanosecond precision use two 64-bit ints.
- nly 3y agoIn my experience unix time in units finer than seconds is more common than not. The NYSE stock exchange uses nanos since Unix epoch as a single 64bit int. I've never seen someone waste a whole second 64bits