Live data from Hacker News

How much your computer can do in a second

computers-are-fast.github.io

1–10 of 244 posts

Re: How much your computer can do in a second

#2
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 implementation and not actually limited by the memory subsystem.

> msgpack_parse.py

Again, a large chunk goes into inefficiencies, not so much the actual work. This is a common pattern in highly abstracted software. msgpack-c mostly works at >200 MB/s or so (obviously a lot faster if you have lots of RAWs or STRs and little structure). Funnily enough, if you link against it and traverse stuff, then a lot of time is spent doing traversals, and not the actual unpacking (in some analysis I've seen a ~1/3 - 2/3 split). So the cost of abstraction also bites here.

If you toy around with ZeroMQ you can see that you'll be able to send around 3 million msg/s between threads (PUSH/PULL) from C or C++, around 300k using pyzmq (this factor 10 is sometimes called "interpreter tax"), but only around 7000 or so if you try to send Python objects using send_pyobj (which uses Pickle). That's a factor 430.

Re: How much your computer can do in a second

#3
post #2

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?

Re: How much your computer can do in a second

#5
post #3
post #2

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?

GCC with -O3 might try to unroll this loop into a single constant. O(0) is pretty fast.

Re: How much your computer can do in a second

#6
post #5
post #3

Earlier quoted context omitted.

How would you optimize sum.c to be faster?

GCC with -O3 might try to unroll this loop into a single constant. O(0) is pretty fast.

That's very likely. Clang 8.0 collapses the loop with any optimizer setting other than -O0.

But if you had to do it manually, loop unrolling and SIMD instructions (although not part of standard C) would be good bets and can probably get you an order of magnitude.

Re: How much your computer can do in a second

#7
post #3
post #2

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?

Well the obvious answer would be, eliminate the loop, which is what any compiler optimizer will do ;)

But let's assume that the operation is not quite so trivial like here, then this structure would be a prime example where each loop operation is independent from each other, so you can sum a vector in parallel (=SIMD) and then sum the vector once in the end.

Also, since we're obviously not using any compiler optimizations, you can unroll the loop, which reduces per-iteration loop overhead (the conditional jump) and in such a simple case as here is bound to give a nice boost.

Re: How much your computer can do in a second

#8
post #5
post #3

Earlier quoted context omitted.

How would you optimize sum.c to be faster?

GCC with -O3 might try to unroll this loop into a single constant. O(0) is pretty fast.

GCC as expected, O>2

        sub     rsp, 8
        mov     rdi, QWORD PTR [rsi+8]
        mov     edx, 10
        xor     esi, esi
        call    strtol              
Interestingly enough it does not elide the entire function body.

Re: How much your computer can do in a second

#9
post #8
post #5

Earlier quoted context omitted.

GCC with -O3 might try to unroll this loop into a single constant. O(0) is pretty fast.

GCC as expected, O>2 sub rsp, 8 mov rdi, QWORD PTR [rsi+8] mov edx, 10 xor esi, esi call strtol Interestingly enough it does not elide the entire function body.

How do you get objdump -S to print out non AT&T syntax? My output looked like this:

    000000000400400 :
      400400:	48 83 ec 08          	sub    $0x8,%rsp
      400404:	48 8b 7e 08          	mov    0x8(%rsi),%rdi
      400408:	ba 0a 00 00 00       	mov    $0xa,%edx
      40040d:	31 f6                	xor    %esi,%esi
      40040f:	e8 dc ff ff ff       	callq  4003f0 
      400414:	31 c0                	xor    %eax,%eax
      400416:	48 83 c4 08          	add    $0x8,%rsp
      40041a:	c3                   	retq   
      40041b:	0f 1f 44 00 00       	nopl   0x0(%rax,%rax,1)

Which I'm not a fan of. I've always wanted "add (store), (get)" but could never get that.

Re: How much your computer can do in a second

#10
post #9
post #8

Earlier quoted context omitted.

GCC as expected, O>2 sub rsp, 8 mov rdi, QWORD PTR [rsi+8] mov edx, 10 xor esi, esi call strtol Interestingly enough it does not elide the entire function body.

How do you get objdump -S to print out non AT&T syntax? My output looked like this: 000000000400400 : 400400: 48 83 ec 08 sub $0x8,%rsp 400404: 48 8b 7e 08 mov 0x8(%rsi),%rdi 400408: ba 0a 00 00 00 mov $0xa,%edx 40040d: 31 f6 xor %esi,%esi 40040f: e8 dc ff ff ff callq 4003f0 400414: 31 c0 xor %eax,%eax 400416: 48 83 c4 08 add $0x8,%rsp 40041a: c3 retq 40041b: 0f 1f 44 00 00 nopl 0x0(%rax,%rax,1) Which I'm not a fan o…

Not on a development machine right now, so I just went to godbolt ;)

https://godbolt.org/

Post reply on HN