Ticket #2902 (closed bug: fixed)

Opened 3 years ago

Last modified 14 months ago

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 Difficulty: Unknown
Test Case: T2902 Blocked By:
Blocking: Related Tickets:

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

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

Change History

Changed 3 years ago by Syzygies

Toy project exhibiting bug

Changed 3 years ago by simonpj

  • cc batterseapower@… added
  • difficulty set to 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

Changed 3 years ago by igloo

  • milestone set to 6.12 branch

Changed 3 years ago by simonmar

  • failure set to Runtime performance bug

Changed 2 years ago by igloo

  • milestone changed from 6.12 branch to 6.12.3

Changed 2 years ago by igloo

  • priority changed from normal to low
  • milestone changed from 6.12.3 to 6.14.1

Changed 18 months ago by igloo

  • milestone changed from 7.0.1 to 7.0.2

Changed 15 months ago by igloo

  • milestone changed from 7.0.2 to 7.2.1

Changed 14 months 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?

Changed 14 months ago by simonmar

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

Changed 14 months 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

Changed 14 months ago by igloo

  • status changed from new to closed
  • testcase set to T2902
  • resolution set to fixed

Test added.

Note: See TracTickets for help on using tickets.