Opened 9 years ago

Closed 7 years ago

#2902 closed bug (fixed)

Example where ghc 6.10.1 fails to optimize recursive instance function calls

Reported by: Syzygies Owned by: igloo
Priority: low Milestone: 7.2.1
Component: Compiler Version: 6.10.1
Keywords: class instance Cc: batterseapower@…, michal.terepeta@…
Operating System: MacOS X Architecture: x86_64 (amd64)
Type of failure: Runtime performance bug Test Case: T2902
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

Using ghc 6.10.1, I get over a 3x performance boost on the attached toy example, by moving instance function definitions out of the instance declaration, so that recursive calls avoid the class dictionary.

According to SPJ, ghc 6.10.1 is supposed to perform this optimization automatically. I am reporting it as a bug at his request, following a discussion on the glasgow-haskell-users@… list.

Attachments (1)

Instance.tar.gz (2.6 KB) - added by Syzygies 9 years ago.
Toy project exhibiting bug

Download all attachments as: .zip

Change History (12)

Changed 9 years ago by Syzygies

Attachment: Instance.tar.gz added

Toy project exhibiting bug

comment:1 Changed 9 years ago by simonpj

Cc: batterseapower@… added
difficulty: Unknown

Ha! Excellent example. What is happening is that I'm generating stuff like

union d = let u2 = union d in \x. ... u2 ...

If only we had Max's arity analysis, this would generate good code (by inlining u2) but now it doesn't. Max, this is an excellent test case.

Simon

comment:2 Changed 9 years ago by igloo

Milestone: 6.12 branch

comment:3 Changed 8 years ago by simonmar

Type of failure: Runtime performance bug

comment:4 Changed 7 years ago by igloo

Milestone: 6.12 branch6.12.3

comment:5 Changed 7 years ago by igloo

Milestone: 6.12.36.14.1
Priority: normallow

comment:6 Changed 7 years ago by igloo

Milestone: 7.0.17.0.2

comment:7 Changed 7 years ago by igloo

Milestone: 7.0.27.2.1

comment:8 Changed 7 years ago by michalt

Cc: michal.terepeta@… added

With current HEAD I'm getting exactly the same run-times in both cases. Maybe this was fixed by the simple arity analyser that was recently implemented?

comment:9 Changed 7 years ago by simonmar

Yes, looks like another case that the arity analyser catches. Simon, do you agree?

comment:10 Changed 7 years ago by simonpj

Owner: set to igloo

Yes, this looks like the same win. Ian, could you add a perf test and close? Thanks

Simon

comment:11 Changed 7 years ago by igloo

Resolution: fixed
Status: newclosed
Test Case: T2902

Test added.

Note: See TracTickets for help on using tickets.