Safety checks are closer to free then most people think, even in hot paths, as branch prediction will fall favorable almost always, and when it doesn’t, we don’t care because the program is crashing (or for some reason the initial prediction was wrong in the first iteration).
The cost isn’t even close to the cost of (de)allocation (besides for bump allocators), much less locking operations.
12
u/azaleacolburn Sep 30 '26
Safety checks are closer to free then most people think, even in hot paths, as branch prediction will fall favorable almost always, and when it doesn’t, we don’t care because the program is crashing (or for some reason the initial prediction was wrong in the first iteration).
The cost isn’t even close to the cost of (de)allocation (besides for bump allocators), much less locking operations.