4 ms·
Article poses good questions, although the load time is terrible[1]. Here's the intro while you are waiting for it: There is one thing which has puzzled me
by nkurz 13y ago
Article poses good questions, although the load time is terrible[1]. Here's the intro while you are waiting for it:
There is one thing which has puzzled me for a while, and
it is the performance of programs written in C when it
comes to big numbers. It may or may not help with the
decades-long ‘C vs Fortran’ performance debate, but let’s
concentrate on one single and reasonably well-defined
thing – big number arithmetic in C and see if it can be
improved.
In fact, there are very few things which gain from being
rewritten in assembler (compared to C), but big number
arithmetic is one of them, with relatively little progress
in this direction over the years. Let’s take a look at
OpenSSL (a library which is among the most concerned about
big number performance: 99% of SSL connections use RSA
these days, and RSA_performance == Big_Number_Performance,
and RSA is notoriously sslloooowww).
...
OpenSSL prefers to use assembler for big number
calculations. It was the case back in 1998, and it is
still the case now (last time I checked, the difference
between C and asm implementations was 2x, but it was long
ago, so things may have easily changed since). But why
should this be the case? Why with all the optimizations
compilers are doing now, should such a common and trivial
thing still need to be written in asm (which has its own
drawbacks – from the need to write it manually for each
and every platform, to sub-optimality of generic asm when
it comes to pipeline optimizations – and hand-rewriting
asm for each new CPU -march/-mtune is not realistic)? If
it can perform in asm but cannot perform in C, it means
that all hardware support is present, but the performance
is lost somewhere in between C developer and generated
binary code; in short – the compiler cannot produce good
code. This article will try to perform some analysis of
this phenomenon.
[1] Maybe they are using IPoAC? It sometimes exhibits high packet loss with heavy rain, particularly on international links: http://en.wikipedia.org/wiki/IP_over_Avian_Carriers http://en.wikipedia.org/wiki/IP_over_Avian_Carriers
- aortega 13y ago> But why should this be the case? Why with all the optimizations compilers are doing now, should such a common and trivial thing still need to be written in asm? Yes, if the CPU vendor keeps coming with all kinds of clowny instructions like MMX/SSE2/SSE4/SSE XP/etc to accelerate things (but really because they need new instructions so the ABI remains patented). Compilers and libraries can't keep with all the new instructions.
- dbaupp 13y agoHigh performance libraries do keep up with the new instructions, e.g. GMP[1] likes the new MULX[2] instruction a lot. [1]: https://gmplib.org/list-archives/gmp-devel/2013-August/003353.html https://gmplib.org/list-archives/gmp-devel/2013-August/00335... [2]: http://www.intel.com/content/www/us/en/intelligent-systems/intel-technology/ia-large-integer-arithmetic-paper.html http://www.intel.com/content/www/us/en/intelligent-systems/i...
- p0nce 13y agoSorry but I _need_ those new instructions.