Ticket #2159 (new bug)

Opened 4 years ago

Last modified 4 months ago

Use a more efficient representation than [DynFlag]

Reported by: igloo Owned by:
Priority: low Milestone: 7.4.1
Component: Compiler Version: 6.8.2
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Compile-time performance bug Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

In compiler/typecheck/TcRnMonad.lhs, if I replace the existing definitions with

traceOptIf _ _ = return ()
traceOptTcRn _ _ = return ()
dumpTcRn _ = return ()

then we see an improvement in nofib's "Compile Times" sections:

-1 s.d.		-----	-8.5%
+1 s.d.		-----	+1.8%
Average		-----	-3.5%

By using some sort of bitmap representation, we ought to see a modest compile time improvement from all the checks that the trace functions make, as well as various other checks that are made (do we need to warn about missing sigs, are overlapping instances allowed, etc).

The tricky bit is designing it so that it is hard to shoot yourself in the foot. Lexer.x already has a bitmap (genericsBit, ffiBit etc) but the mapping of feature to bit number is done by hand, which isn't ideal. Perhaps this is even important enough to deserve a language extension?

Attachments

bitmap.dpatch Download (220.5 KB) - added by igloo 16 months ago.

Change History

  Changed 3 years ago by simonmar

  • architecture changed from Unknown to Unknown/Multiple

  Changed 3 years ago by simonmar

  • os changed from Unknown to Unknown/Multiple

  Changed 3 years ago by igloo

  • milestone changed from 6.10 branch to 6.12 branch

  Changed 2 years ago by simonmar

  • failure set to Compile-time performance bug

  Changed 22 months ago by igloo

  • milestone changed from 6.12 branch to 6.12.3

  Changed 20 months ago by igloo

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

  Changed 16 months ago by igloo

With plain HEAD, and HEAD with bitmap.dpatch, running

time ghc -v0 --make -O Setup.hs

in a Cabal tree (which thus also builds most of Cabal) I get:

Run 1
    HEAD:           111.38 user 1.39 system 1:52.88 elapsed
    Bitmap:         109.01 user 1.38 system 1:50.41 elapsed
Run 2
    HEAD:           112.18 user 1.32 system 1:53.55 elapsed
    Bitmap:         110.58 user 1.38 system 1:51.98 elapsed
Run 3
    HEAD:           97.51 user 1.23 system 1:38.75 elapsed
    Bitmap:         110.95 user 1.26 system 1:52.24 elapsed
Run 4
    HEAD:           111.60 user 1.33 system 1:52.92 elapsed
    Bitmap:         109.93 user 1.30 system 1:51.31 elapsed
Run 5
    HEAD:           111.63 user 1.66 system 1:53.31 elapsed
    Bitmap:         88.90 user 1.19 system 1:30.41 elapsed
Run 6
    HEAD:           95.12 user 1.26 system 1:36.47 elapsed
    Bitmap:         111.27 user 1.48 system 1:52.88 elapsed
Run 7
    HEAD:           112.18 user 1.35 system 1:53.66 elapsed
    Bitmap:         109.51 user 1.27 system 1:50.85 elapsed
Run 8
    HEAD:           112.51 user 1.16 system 1:53.74 elapsed
    Bitmap:         110.33 user 1.26 system 1:51.71 elapsed
Run 9
    HEAD:           111.69 user 1.36 system 1:53.37 elapsed
    Bitmap:         109.26 user 1.40 system 1:50.65 elapsed
Run 10
    HEAD:           114.77 user 1.38 system 1:56.24 elapsed
    Bitmap:         110.08 user 1.47 system 1:51.54 elapsed

so with the patch it takes 109-110 rather than 111-112s (although occasionally a build is much quicker).

So not a huge performance increase, but it removes one of the slivers, and it would be nice to get the dopt noise out of profiles. I think some sort of extension (or generic program?) that makes bitmaps from enumerations would be generally useful.

Changed 16 months ago by igloo

follow-up: ↓ 9   Changed 16 months ago by igloo

I don't think we should apply the patch, incidentally. It would be a maintenance nightmare.

in reply to: ↑ 8   Changed 16 months ago by simonmar

Replying to igloo:

I don't think we should apply the patch, incidentally. It would be a maintenance nightmare.

That's what I thought too when I saw it. Have you tried just using an IntMap?

  Changed 14 months ago by igloo

  • milestone changed from 7.0.1 to 7.0.2

  Changed 11 months ago by igloo

  • milestone changed from 7.0.2 to 7.2.1

  Changed 4 months ago by igloo

  • milestone changed from 7.2.1 to 7.4.1
Note: See TracTickets for help on using tickets.