Time to move std.experimental.checkedint to std.checkedint ?

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Mon Mar 29 16:41:12 UTC 2021


On 3/27/21 3:42 AM, tsbockman wrote:
> With good inlining and optimization, even a library solution generally 
> slows integer math code down by less than a factor of two. (I expect a 
> language solution could do even better.)
> 
> This is significant, but nowhere near big enough to move the bottleneck 
> in most code away from I/O, memory, floating-point, or integer math for 
> which wrapping is semantically correct (like hashing or encryption). In 
> those cases where integer math code really is the bottleneck, there are 
> often just a few hot spots where the automatic checks in some inner loop 
> need to be replaced with manual checks outside the loop.

This claim seems speculative. A factor of two for a fundamental class of 
operations is very large, not just "significant". We're talking about 
e.g. 1 cycle for addition, and it was a big deal when it was introduced 
back in the early 2000s. Checked code is larger, meaning more pressure 
on the scarce I-cache in large programs - and that's not going to be 
visible in microbenchmarks. And "I/O is slow anyway" is exactly what 
drove the development of C++ catastrophically slow iostreams.


More information about the Digitalmars-d mailing list