Opened 3 years ago

Closed 3 years ago

#4450 closed bug (invalid)

Do stack squeezing before expanding stack

Reported by: simonpj Owned by: simonmar
Priority: normal Milestone:
Component: Compiler Version: 6.12.3
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Difficulty:
Test Case: Blocked By:
Blocking: Related Tickets:

Description

The presenting effect is that nofib/spectral/hartel/genfft exhibits non-deterministic allocation behaviour:

./fft-noticky 7 +RTS -sstderr 
13735234/185243
     112,177,208 bytes allocated in the heap
      61,405,448 bytes copied during GC
      15,156,968 bytes maximum residency (8 sample(s))
      13,590,616 bytes maximum slop
              40 MB total memory in use (8 MB lost due to fragmentation)

  Generation 0:   151 collections,     0 parallel,  0.10s,  0.10s elapsed
  Generation 1:     8 collections,     0 parallel,  0.06s,  0.06s elapsed

  INIT  time    0.00s  (  0.00s elapsed)
  MUT   time    0.08s  (  0.08s elapsed)
  GC    time    0.16s  (  0.16s elapsed)
  EXIT  time    0.00s  (  0.00s elapsed)
  Total time    0.25s  (  0.25s elapsed)

  %GC time      66.3%  (66.8% elapsed)

  Alloc rate    1,343,359,176 bytes per MUT second

  Productivity  32.9% of total user, 33.1% of total elapsed

-----------------------------
./fft-noticky 7 +RTS -sstderr 
13735234/185243
     114,257,976 bytes allocated in the heap
      61,405,448 bytes copied during GC
      15,156,968 bytes maximum residency (8 sample(s))
      14,622,696 bytes maximum slop
              40 MB total memory in use (6 MB lost due to fragmentation)

  Generation 0:   151 collections,     0 parallel,  0.11s,  0.11s elapsed
  Generation 1:     8 collections,     0 parallel,  0.06s,  0.06s elapsed

  INIT  time    0.00s  (  0.00s elapsed)
  MUT   time    0.08s  (  0.08s elapsed)
  GC    time    0.17s  (  0.17s elapsed)
  EXIT  time    0.00s  (  0.00s elapsed)
  Total time    0.25s  (  0.25s elapsed)

  %GC time      66.4%  (66.8% elapsed)

  Alloc rate    1,354,200,704 bytes per MUT second

  Productivity  32.9% of total user, 33.0% of total elapsed

The non-determinism goes away with the RTS opt -V0.

In discussion we think the allocation differs because stack-squeezing happens differently in the two runs.

Change History (2)

comment:1 Changed 3 years ago by simonpj

  • Owner set to simonmar

comment:2 Changed 3 years ago by simonmar

  • Resolution set to invalid
  • Status changed from new to closed

When the stack overflows, we do stack squeezing and then we also expand the stack, just in case stack squeezing doesn't actually recover any stack space and to avoid thrashing.

So what happens in this example is that the context switches cause a little extra squeezing to happen, which means the stack overflows a little later, and we might end up expanding it less, depending on when the context switches strike. So, nothing really strange going on - use +RTS -V0 to get deterministic results.

Note: See TracTickets for help on using tickets.