`RTSecret<T, std::cell::Cell<u8>>` is the same size as `RTSecret<T, std::cell::Cell<u16>>`, why? And how to optimize such that former is smaller than latter?

No problem; I've tried to explain my calculations clearly so that you can repeat the process I went through for "why not u128" in your later work. If anything I did is unclear, please do ask; these sorts of calculations (which you can do in your head if you know enough usable approximations) are useful tools to avoid spending too much time on low value things.

You should only care about widths that you know you're going to support. 32 and 64 matter because you know you'll be supporting at least one of x86, RISC-V or ARM, where 8, 16 and 32 bit atomics always exist and 64 bit atomics definitely exist on the 64 bit variants, but until you know that you're dealing with a machine that has 7 or 31 bit atomics, don't bother adding support. Basically, don't add code to support a case that you're not yet confident you want to handle.

3 Likes