Ticket #6166 (new bug)

Opened 11 months ago

Last modified 8 months ago

Performance regression in mwc-random since 7.0.x

Reported by: bos Owned by:
Priority: high Milestone: 7.6.2
Component: Compiler Version: 7.4.2
Keywords: Cc: pho@…, dima@…, bgamari@…
Operating System: Unknown/Multiple Architecture: x86_64 (amd64)
Type of failure: Runtime performance bug Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

I've had a report that the performance of the mwc-random package has regressed seriously after upgrading from GHC 7.0 to 7.4. It turns out that 7.2 also has the regression.

Here's a sample program.

import qualified Data.Vector.Unboxed as U

import qualified System.Random.MWC as R
import System.Random.MWC.Distributions (standard)

count = 1000 * 1000

fast gen = standard gen

slow gen = standard gen >>= return

-- Edit this to choose fast or slow.
which gen = slow gen

main = do
  gen <- R.create
  v <- U.replicateM count (which gen)
  print (U.last v)

With GHC 7.0.3 -O2, this runs in 0.294 sec, regardless of whether fast or slow is used.

Under 7.4, fast runs in 0.062 sec (a nice speedup!), but slow now takes 9.2 sec (yikes!).

Roman suggested compiling the slow version with -fno-state-hack, which brings performance back up to 0.062 sec.

Change History

Changed 11 months ago by simonmar

  • priority changed from normal to high
  • difficulty set to Unknown
  • milestone set to 7.6.1

We should look into this: -fno-state-hack should never make something faster; the whole point of the state hack is to improve performance.

Changed 11 months ago by PHO

  • cc pho@… added

Changed 10 months ago by Dzhus

  • cc dima@… added

Changed 10 months ago by bgamari

  • cc bgamari@… added

Changed 10 months ago by Dzhus

Still present in 7.5.20120718

Changed 8 months ago by igloo

  • milestone changed from 7.6.1 to 7.6.2
Note: See TracTickets for help on using tickets.