More impressively, sum.c could go likely an order of magnitude or so faster, when optimized. > Friends who do high performance networking say it's possible to get network roundtrips of 250ns (!!!), Well stuff like Infiniband is less network, and more similar to a bus (e.g. RDMA, atomic ops like fetch-and-add or CAS). > write_to_memory.py Is also interesting because this is dominated by inefficiencies in the API and i…
How would you optimize sum.c to be faster?
But assuming his CPU takes one cycle for an addition and one cycle for a conditional jump, his CPU only needs to run at 1GHz to achieve his result.
Given that branch prediction should be nearly perfect for such a simple and short loop, modern x86 CPUs doing at least 4 integer additions per cycle, and typical CPU speeds in the range of 2-4 GHz, a properly optimized version should be nearly an order of magnitude faster.
So either more aggressive compiler flags and maybe SIMD intrinsics, or hand written assembly (easy here, not so easy in the real world)