Latency Comparisons every programmer should know (2012)
gist.github.com
gist.github.com
In billions: L1 cache reference can be done 2 billion times per second.
In millions: Branch mispredict, L2 cache reference, Mutex lock/unlock and Main memory reference can be done 200, 140, 40 and 10 million times per second.
In thousands: Compress 1K bytes with Zippy, Send 2K bytes over 1 Gbps network, SSD random read, Read 1 MB sequentially from memory, Round trip within same datacenter and Read 1 MB sequentially from SSD* can be done 300, 50, 7, 4, 2 and 1 thousand times per second.
And finally, Disk seek, Read 1 MB sequentially from disk and Send packet CA->Netherlands->CA can be done 100, 50 and 7 times per second.
No graphs needed, or trying to figure out is a microsecond much or not.
if its in ram, then like ram.
then size/amount of parameters affects it, and its not continuous because at some threshold compilers may start doing it differently.
Context switches are closer to about 1µs in the best case, with interprocess context switches maybe reaching 5µs. The time here is much more variable because the really painful thing is the effect of TLB flushing and other microarchitectural state going completely haywire.
Isn't context switch also where spectre/meltdown mitigations hit the hardest, too?
Instant coffee?
Maybe French press, if the water is already boiling.
An execution unit is basically an ALU with a set of muxes for inputs, where the muxes are pulling either from the registers or from later execution stages that have yet to commit their results to registers. The entire path has to settle down by the time the clock signal reaches the latch at the edge of the stage to retain the value for the next clock cycle. This means that the time it takes to read a register is a fraction of the single clock cycles that 1-clock-cycle µops take to run.
When looking at compiler output of gcc most of the time it puts variables within a scope on the stack and rarely populates all registers or even any at all. Wouldn't using the full 12-14 available first be faster?
As for your second question, my guess is you're looking at unoptimized code. Most compilers keep variables on the stack unless you're optimizing the code to at least some degree.