Re: Strange performance behaviour

  • From: David Given <dg@xxxxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Sat, 25 Aug 2012 23:20:02 +0100

On 25/08/12 22:48, Drake Wilson wrote:
> This specific example _can_ exhibit similar behavior in C.  I imagine
> this is because repeatedly doing buffer[0] = buffer[0] + buffer[0] *
> 0.1 will (assuming it starts out initialized to a nonzero finite) take
> that value toward an infinity pretty fast, and operations on
> non-normalized values (Inf, NaN, denormal) can be much slower for the
> FPU to execute.

Just for your information (not that I think it's happening here): glibc
contains some *excruciatingly* pathalogical code paths.

For example, here's a guy discovering that the same number of iterations
of a simple benchmark with pow() can, if you change the exponent
slightly, vary from 10 seconds to 21 *hours*.

I found this myself when trying to run the Whetstone benchmark on a
device and noticing that it was apparently hanging. In my case it was
with exp():

Turns out that under some circumstances in glibc the exp()
implementation will try to calculate the result using multiprecision

┌─── ───── ─────
│ life←{ ↑1 ⍵∨.^3 4=+/,¯1 0 1∘.⊖¯1 0 1∘.⌽⊂⍵ }
│ --- Conway's Game Of Life, in one line of APL

Other related posts: