input-output-hk / io-sim

Haskell's IO simulator which closely follows core packages (base, async, stm).
https://hackage.haskell.org/package/io-sim
Apache License 2.0
37 stars 15 forks source link

Refactor IOSimPOR #114

Closed coot closed 1 year ago

coot commented 1 year ago

A long list of self contained patches. See CHANGELOG.md for a short description of all the changes.

coot commented 1 year ago

With unsafeInterleaveST

conjoinParST :: TestableNoCatch prop => [ST s prop] -> ST s Property
conjoinParST sts = do
    ps <- sequence (unsafeInterleaveST <$> sts)
    return $ conjoinPar ps
N Total Elapsed MUT MUT Elapsed
1 74.625s 74.520s 59.564s 59.423s
2 93.936s 58.870s 71.665s 44.233s
3 103.538s 55.560s 78.795s 42.647s
4 111.185s 54.310s 83.378s 41.874s
5 113.673s 53.420s 84.926s 41.594s
6 119.478s 53.920s 88.528s 42.048s
7 124.710s 54.120s 92.008s 42.428s
8 119.583s 51.430s 88.580s 40.912s
9 129.239s 53.010s 94.851s 42.084s
10 126.762s 52.070s 93.471s 41.733s
11 130.695s 52.080s 95.989s 41.832s
12 136.149s 52.570s 99.176s 42.127s
-- ---------- --------- ---------- -------------
24 177.372s 58.281s 123.908s 46.076s

Note: on a machine ith 12 physical cores, 24 CPU threads.

Without unsafeInterleaveST

conjoinParST :: TestableNoCatch prop => [ST s prop] -> ST s Property
conjoinParST sts = do
    ps <- sequence sts
    return $ conjoinPar ps
N Total Elapsed MUT MUT Elapsed
1 84.907s 84.790s 62.006s 61.850s
2 101.086s 89.570s 69.277s 69.025s
3 104.942s 88.220s 70.331s 69.479s
4 106.666s 86.870s 70.994s 69.499s
5
6 108.294s 85.110s 72.338s 69.597s
7
8
9
10 121.869s 86.000s 75.760s 70.053s
11
12 129.112s 86.470s 77.958s 70.382s
dcoutts commented 1 year ago

Any idea why the with/without unsafeInterleaveST is 10s different @ -N1? 74 vs 84s @ -N1

coot commented 1 year ago

No, it's a bit surprising. When I run it now I get similar results. Different test case, and previously I was running with profiling, this time without. Still there's a 10% difference.

Par

N Total Elapsed
1 7.529 7.530
6 11.648 5.610
12 13.709 5.550

Seq

N Total Elapsed
1 8.177 8.170
6 11.513 8.700
12 12.646 8.400
coot commented 1 year ago

@bolt12 I addressed your review. I accepted most of your comments, the one that I challenged I left opened.