Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Constrained version of Probability #3

Open
wants to merge 6 commits into
base: Markov
Choose a base branch
from
Open

Conversation

chrisdone
Copy link
Collaborator

This concludes the test of using a constrained-normal monad wrapper over Probability.

  • With RepeatedPD, I see the proper results for 53/54 iterations (fail, succeed)
  • With AndGateMarkov, I see a significant speed-up with
    • The constrained monad, though I'm not sure why exactly it introduces better speed. It goes from 30s to 20s. 25G to 16G allocations.
    • Adding O.norm on the right-hand side of >>= seems to shave off a couple seconds off runtime. 20s to 17s, retains the 16G allocations.

An interesting direction could be to put a Set (p,a) instead of [(p,a)], but it'd probably only save a tiny amount (by avoiding the Data.Map.toList/Data.Map.fromList on every bind).

Note that these results are in GHCi, because we're interested in complexity more than GHC's optimizations. Here's compiled with -O:

Original

     325,369,072 bytes allocated in the heap
      33,202,640 bytes copied during GC
         233,632 bytes maximum residency (17 sample(s))
          30,328 bytes maximum slop
               0 MB total memory in use (0 MB lost due to fragmentation)

                                     Tot time (elapsed)  Avg pause  Max pause
  Gen  0       297 colls,     0 par    0.032s   0.032s     0.0001s    0.0002s
  Gen  1        17 colls,     0 par    0.004s   0.004s     0.0003s    0.0005s

  INIT    time    0.000s  (  0.000s elapsed)
  MUT     time    0.077s  (  0.077s elapsed)
  GC      time    0.036s  (  0.036s elapsed)
  EXIT    time    0.000s  (  0.000s elapsed)
  Total   time    0.113s  (  0.113s elapsed)

  %GC     time       0.0%  (0.0% elapsed)

  Alloc rate    4,237,404,076 bytes per MUT second

  Productivity  67.9% of total user, 67.9% of total elapsed

Constrained normal

     158,513,840 bytes allocated in the heap
       5,184,864 bytes copied during GC
         119,280 bytes maximum residency (3 sample(s))
          29,320 bytes maximum slop
               0 MB total memory in use (0 MB lost due to fragmentation)

                                     Tot time (elapsed)  Avg pause  Max pause
  Gen  0       150 colls,     0 par    0.007s   0.007s     0.0000s    0.0001s
  Gen  1         3 colls,     0 par    0.000s   0.000s     0.0002s    0.0002s

  INIT    time    0.000s  (  0.000s elapsed)
  MUT     time    0.044s  (  0.044s elapsed)
  GC      time    0.007s  (  0.007s elapsed)
  EXIT    time    0.000s  (  0.000s elapsed)
  Total   time    0.051s  (  0.051s elapsed)

  %GC     time       0.0%  (0.0% elapsed)

  Alloc rate    3,607,835,032 bytes per MUT second

  Productivity  85.3% of total user, 85.4% of total elapsed

norm on rhs

     151,945,968 bytes allocated in the heap
       5,815,064 bytes copied during GC
         132,128 bytes maximum residency (3 sample(s))
          29,320 bytes maximum slop
               0 MB total memory in use (0 MB lost due to fragmentation)

                                     Tot time (elapsed)  Avg pause  Max pause
  Gen  0       143 colls,     0 par    0.007s   0.008s     0.0001s    0.0002s
  Gen  1         3 colls,     0 par    0.000s   0.000s     0.0002s    0.0002s

  INIT    time    0.000s  (  0.000s elapsed)
  MUT     time    0.041s  (  0.045s elapsed)
  GC      time    0.008s  (  0.008s elapsed)
  EXIT    time    0.000s  (  0.000s elapsed)
  Total   time    0.049s  (  0.054s elapsed)

  %GC     time       0.0%  (0.0% elapsed)

  Alloc rate    3,706,812,910 bytes per MUT second

  Productivity  84.5% of total user, 84.1% of total elapsed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant