Opened 5 years ago

Closed 5 years ago

#9326 closed bug (invalid)

Minor change to list comprehension structure leads to poor performance

Reported by: dfeuer Owned by:
Priority: normal Milestone:
Component: Compiler Version: 7.8.3
Keywords: Cc: jan.stolarek@…, slyfox
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Runtime performance bug Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description (last modified by dfeuer)

According to http://stackoverflow.com/questions/24690406/haskell-list-comprehension-speed-inconsistencies and my own testing, the code in compspeed.hs reliably runs several times faster than the code in compspeedslow.hs with ghc 7.8.3. It seems 7.8.3 is compiling the "fast" code better than 7.6.3 did, but compiling the "slow" code about the same. The basic distinction is between a list comprehension of the form

[(a,h) | ..., let h = expr]

and

[(a,expr) | ...]

The core produced by -ddump-simpl is completely different in each case, so I can't figure out what's going on.

Attachments (3)

compspeed.hs (1.9 KB) - added by dfeuer 5 years ago.
The fast one
compspeedslow.hs (1.8 KB) - added by dfeuer 5 years ago.
The slow one
matrix.txt (30.6 KB) - added by dfeuer 5 years ago.
The file both operate on.

Download all attachments as: .zip

Change History (7)

Changed 5 years ago by dfeuer

Attachment: compspeed.hs added

The fast one

Changed 5 years ago by dfeuer

Attachment: compspeedslow.hs added

The slow one

Changed 5 years ago by dfeuer

Attachment: matrix.txt added

The file both operate on.

comment:1 Changed 5 years ago by dfeuer

Description: modified (diff)

comment:2 Changed 5 years ago by jstolarek

Cc: jan.stolarek@… added

comment:3 Changed 5 years ago by slyfox

Cc: slyfox added

In 'comdspeed' one more rule did fire (to specialze .find on Ints):

"SPEC find [(Int, Int)]" [ALWAYS]
    forall @ a3_a2Tz $dOrd_s2U0. find $dOrd_s2U0 = $sfind

It's seen in core comparison when use -ddump-simp -dsuppress-all.

Last edited 5 years ago by slyfox (previous) (diff)

comment:4 Changed 5 years ago by dfeuer

Resolution: invalid
Status: newclosed

It looks like the original reporter was able to resolve the problem by adding some type signatures to get things specialized earlier.

Note: See TracTickets for help on using tickets.