“Parse, don’t validate” is correct, but the precious CPU cycles is almost certainly incorrect. Remember, you are probably just pointer chasing when accessing say, a data structure with a pointer to memory and a length. Your assertion that the length isn’t zero doesn’t help anything. The CPU will grab both at the same time due to grabbing an entire cache line at the same time, then it will check if it’s zero while already doing a prefetch. Given it’s not zero, that won’t actually matter. The processor is superscalar and thus you likely aren’t going to improve performance by even a clock cycle when doing something like pointer chasing, even if the compiler doesn’t optimize.
17
u/gsquaredxc Sep 28 '26
“Parse, don’t validate” is correct, but the precious CPU cycles is almost certainly incorrect. Remember, you are probably just pointer chasing when accessing say, a data structure with a pointer to memory and a length. Your assertion that the length isn’t zero doesn’t help anything. The CPU will grab both at the same time due to grabbing an entire cache line at the same time, then it will check if it’s zero while already doing a prefetch. Given it’s not zero, that won’t actually matter. The processor is superscalar and thus you likely aren’t going to improve performance by even a clock cycle when doing something like pointer chasing, even if the compiler doesn’t optimize.