3 ms·
Turning every load or store from one instruction into two sounds slow; pNaCl can't arrive soon enough.
by wmf 16y ago
Turning every load or store from one instruction into two sounds slow; pNaCl can't arrive soon enough.
- pjscott 16y agoIt sounds slow, but think about what's going on in the processor. Memory access instructions are far slower than simple arithmetic instructions. As for the conditional nature of the load instructions, I'm sure that the Cortex-A9 branch predictor will make the overhead from that pretty close to negligible. And there's probably something similar on the Cortex-A8, though I haven't checked. In other words, this is a lot less slow than it sounds.
- mansr 16y agoThe branch predictor is not involved here since there is no branch. A conditional non-branch instruction is, on most implementations, scheduled identically to the unconditional base instruction. A load/store instruction whose condition passes thus executes identically to an unconditional one. If the condition fails, it schedules as though it had hit L1 cache. The main problem I see here is significantly increased code size, which will put additional pressure on the L1 I-cache.
- jbri 16y agoFast code doesn't touch memory that often - if you're doing enough loads/stores that the extra instruction is significant, you're probably bounded by memory latency instead of processor speed anyway. And the most common "frequent" accesses (stack space) don't require those checks.
- repsilat 16y agoWon't iterating over a heap-allocated array result in a load for every element? A lot of good C will keep a lot in L1, but it won't always be in registers or on the stack.
- jbri 16y agoYes, there you'll be incurring the huge performance penalty of one additional instruction per element in the array. As I said, not really significant unless your loop is so tight that memory latency is the big limiter anyway.