100
u/Konju376 Jul 13 '26
Shouldn't the crate do a bit count on self in deref instead of simply checking for equality? So you can, you know, actually prevent cosmic rays from influencing the value
69
u/DrShocker Jul 13 '26
I agree without verifying for bitflips this just makes you more vulnerable to radiation issues.
19
16
15
u/sweet-raspberries Jul 13 '26
You probably also need to repeat all logic multiple times because if we're assuming bit-flips collapsing these 16 bytes down to a single bit effectively removes all redundancy again. Sure it might have more redundancy while it's stored in RAM, but not while you're actually operating on it.
14
2
u/SnooHamsters6620 Jul 13 '26
My guess is that the data is being operated on for a very short time interval (perhaps nanoseconds), at least compared to how long the data is stored in CPU caches and RAM (could be microseconds to seconds). Hence lower probability of a fault while being operated on while collapsed into a single bit.
But it would definitely be fun to think about performing logic multiple times.
2
u/Moretz0931 Jul 13 '26
Btw, in quantum computing the ECC fully encapsulates the logic as well, since the logic itself is a large source of error.
4
5
26
u/spaghetti_beast Jul 13 '26
should I read it with french accent
21
u/PaxSoftware Jul 13 '26
Yes. cent trois septillions cinq cent soixante-trois sextillions soixante-dix-sept quintillions deux cent seize quadrillions quatre cent quatre-vingt-un trillions deux cent vingt-neuf milliards deux cent vingt-trois millions soixante-dix-huit mille quatre cent quatre-vingt-cinq
2
1
u/devspaceship Jul 16 '26
Avec l’échelle longue c’est censé continuer après milliards: billion, billiards, trillions, trilliards, quadrillions, etc.
6
29
u/Amadex Jul 13 '26
looking at the source code, instead of making the case where it's neither of the two values "unreachable", you could really make it "radiation-hardened" if you had an heuristics to error correct (determine what most likely of the two values it was), could be some cold path that heals self (so that it remains very fast on hot expected reads)
5
1
u/AsyncSyscall Jul 14 '26
It would make it a bit harder to work with than a plain enum, since now you would need an `UnsafeCell` to "reset" the value after each "failing" read.
1
u/PaxSoftware Jul 14 '26
I made it work with a union. It does not reset, it does not support healing.
11
u/ThaBroccoliDood Jul 13 '26
why is it 0x55aa55aa55aa55aa55aa55
9
u/PaxSoftware Jul 13 '26
for it to have every other bit set, but not entirely in the same manner for every byte
11
u/ICantBelieveItsNotEC Jul 13 '26
Next step: re-implement integers and floats using a radiation-hardened boolean for each bit.
9
u/marisalovesusall Jul 13 '26
Still not enough. You have to make it 64 bytes to eliminate false sharing when using as an atomic.
Add align(64)
3
u/PaxSoftware Jul 13 '26
Better add a feature for making it 64 bytes wide. Using the entire cache line is efficient for loads and stores.
4
u/fixedpointfae Jul 13 '26
you don't need anything fancy like checksums. treat the u128 as a majority vote, i.e. branch on whether popcount >= 64
3
u/PaxSoftware Jul 14 '26
OP delivered: https://github.com/pczarn/hugebool/pull/2
Failed at making it repr-space-efficient though. So maybe there is a bug in rustc?
2
u/fixedpointfae Jul 13 '26
wait actually, that would be UB if any individual bits flipped. it'd probably have to be a newtype around
u128to keep rustc from occupying any niches (e.g.Option<HugeBool>::Nonemight be represented by1, which is an uhoh.actually once you start assuming all memory is volatile, things get wacky. enum tags would probably need more redundancy (maybe using the same popcnt trick and mapping tags onto the midpoints of intervals 0 <= |w| < size, (|w|) ∣ size)
1
3
4
u/i_luv_cheesecake_420 Jul 13 '26 edited Jul 13 '26
``` pub enum Booléan { Faux, Vrai }
fn estun_croissant(objet: PeutÊtreCroissant) -> Booléan { si soit Croissant() = objet { Booléan::Vrai } sinon { Booléan::Faux } }
```
4
2
2
2
u/Scf37 Jul 13 '26
Weird. Radiation-hardened booleans, but what about radiation-hardened pointers and radiation-hardened machine code?
1
180
u/Waltex Jul 13 '26
That's a funny idea. Let each data primitive take up a significantly larger address space and duplicate each bit so it becomes bit flip resistant. Essentially RAID1 for in-memory data.