Skip to content

Commit 03387bd

Browse files
committed
Fix benchmarks to work on modern GHC.
1 parent 17cbba7 commit 03387bd

File tree

4 files changed

+33
-22
lines changed

4 files changed

+33
-22
lines changed

bench-cbits/checkCapability.c

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ typedef struct Task_ {
4242
// or just continue immediately. It's a workaround for the fact
4343
// that signalling a condition variable doesn't do anything if the
4444
// thread is already running, but we want it to be sticky.
45-
rtsBool wakeup;
45+
bool wakeup;
4646
#endif
4747

4848
// This points to the Capability that the Task "belongs" to. If
@@ -62,14 +62,14 @@ typedef struct Task_ {
6262
// The current top-of-stack InCall
6363
struct InCall_ *incall;
6464

65-
nat n_spare_incalls;
65+
uint32_t n_spare_incalls;
6666
struct InCall_ *spare_incalls;
6767

68-
rtsBool worker; // == rtsTrue if this is a worker Task
69-
rtsBool stopped; // this task has stopped or exited Haskell
68+
bool worker; // == rtsTrue if this is a worker Task
69+
bool stopped; // this task has stopped or exited Haskell
7070

7171
// So that we can detect when a finalizer illegally calls back into Haskell
72-
rtsBool running_finalizers;
72+
bool running_finalizers;
7373

7474
// Links tasks on the returning_tasks queue of a Capability, and
7575
// on spare_workers.
@@ -88,7 +88,7 @@ struct Capability_ {
8888
StgFunTable f;
8989
StgRegTable r;
9090

91-
nat no; // capability number.
91+
uint32_t no; // capability number.
9292

9393
// The Task currently holding this Capability. This task has
9494
// exclusive access to the contents of this Capability (apart from
@@ -98,12 +98,12 @@ struct Capability_ {
9898

9999
// true if this Capability is running Haskell code, used for
100100
// catching unsafe call-ins.
101-
rtsBool in_haskell;
101+
bool in_haskell;
102102

103103
// Has there been any activity on this Capability since the last GC?
104-
nat idle;
104+
uint32_t idle;
105105

106-
rtsBool disabled;
106+
bool disabled;
107107

108108
// The run queue. The Task owning this Capability has exclusive
109109
// access to its run queue, so can wake up threads without
@@ -159,7 +159,7 @@ struct Capability_ {
159159
#if defined(THREADED_RTS)
160160
// Worker Tasks waiting in the wings. Singly-linked.
161161
Task *spare_workers;
162-
nat n_spare_workers; // count of above
162+
uint32_t n_spare_workers; // count of above
163163

164164
// This lock protects:
165165
// running_task
@@ -192,10 +192,9 @@ struct Capability_ {
192192

193193
// Per-capability STM-related data
194194
StgTVarWatchQueue *free_tvar_watch_queues;
195-
StgInvariantCheckQueue *free_invariant_check_queues;
196195
StgTRecChunk *free_trec_chunks;
197196
StgTRecHeader *free_trec_headers;
198-
nat transaction_tokens;
197+
uint32_t transaction_tokens;
199198
} // typedef Capability is defined in RtsAPI.h
200199
// We never want a Capability to overlap a cache line with anything
201200
// else, so round it up to a cache line size:

bench/Main.hs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import qualified Data.Dependent.Map as DMap
2020
import Data.Dependent.Sum
2121
import Data.Functor.Misc
2222
import Data.IORef
23+
import Data.Maybe (fromJust)
2324
import Reflex
2425
import Reflex.Host.Class
2526

@@ -70,7 +71,7 @@ micros =
7071
, withSetupWHNF "fireEventsOnly"
7172
(newEventWithTriggerRef >>= subscribePair)
7273
(\(_, trigger) -> do
73-
Just key <- liftIO $ readIORef trigger
74+
key <- fromJust <$> liftIO (readIORef trigger)
7475
fireEvents [key :=> Identity (42 :: Int)])
7576
, withSetupWHNF "fireEventsAndRead(head/merge1)"
7677
(setupMerge 1 >>= subscribePair)
@@ -84,26 +85,26 @@ micros =
8485
, withSetupWHNF "fireEventsOnly(head/merge100)"
8586
(setupMerge 100 >>= subscribePair)
8687
(\(_, t:_) -> do
87-
Just key <- liftIO $ readIORef t
88+
key <- fromJust <$> liftIO (readIORef t)
8889
fireEvents [key :=> Identity (42 :: Int)])
8990
, withSetupWHNF "hold" newEventWithTriggerRef $ \(ev, _) -> hold (42 :: Int) ev
9091
, withSetupWHNF "sample" (newEventWithTriggerRef >>= hold (42 :: Int) . fst) sample
9192
]
9293

9394
setupMerge :: Int
94-
-> SpiderHost Global ( Event (SpiderEnv Global) (DMap (Const2 Int a) Identity)
95+
-> SpiderHost Global ( Event (SpiderTimeline Global) (DMap (Const2 Int a) Identity)
9596
, [IORef (Maybe (EventTrigger Spider a))]
9697
)
9798
setupMerge num = do
9899
(evs, triggers) <- unzip <$> replicateM num newEventWithTriggerRef
99100
let !m = DMap.fromList [Const2 i :=> v | (i,v) <- zip [0..] evs]
100101
pure (merge m, triggers)
101102

102-
subscribePair :: (Event (SpiderEnv Global) a, b) -> SpiderHost Global (EventHandle (SpiderEnv Global) a, b)
103+
subscribePair :: (Event (SpiderTimeline Global) a, b) -> SpiderHost Global (EventHandle (SpiderTimeline Global) a, b)
103104
subscribePair (ev, b) = (,b) <$> subscribeEvent ev
104105

105-
fireAndRead :: IORef (Maybe (EventTrigger (SpiderEnv Global) a)) -> a -> EventHandle (SpiderEnv Global) b
106+
fireAndRead :: IORef (Maybe (EventTrigger (SpiderTimeline Global) a)) -> a -> EventHandle (SpiderTimeline Global) b
106107
-> SpiderHost Global (Maybe b)
107108
fireAndRead trigger val subd = do
108-
Just key <- liftIO $ readIORef trigger
109+
key <- fromJust <$> liftIO (readIORef trigger)
109110
fireEventsAndRead [key :=> Identity val] $ readEvent subd >>= sequence

bench/RunAll.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ benchmarks = implGroup "spider" runSpiderHost cases
136136
pattern RunTestCaseFlag = "--run-test-case"
137137

138138
spawnBenchmark :: String -> Benchmark
139-
spawnBenchmark name = Benchmark name $ Benchmarkable $ \n -> do
139+
spawnBenchmark name = bench name . toBenchmarkable $ \n -> do
140140
self <- getExecutablePath
141141
callProcess self [RunTestCaseFlag, name, show n, "+RTS", "-N1"]
142142

reflex.cabal

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,20 +303,27 @@ test-suite rootCleanup
303303

304304
benchmark spider-bench
305305
type: exitcode-stdio-1.0
306-
hs-source-dirs: bench
306+
hs-source-dirs: bench test
307307
main-is: Main.hs
308308
ghc-options: -Wall -O2 -rtsopts
309309
build-depends:
310310
base,
311-
criterion == 1.1.*,
311+
containers,
312+
criterion >= 1.1 && < 1.6,
312313
deepseq >= 1.3 && < 1.5,
313314
dependent-map,
314315
dependent-sum,
316+
ref-tf,
315317
mtl,
316318
primitive,
317319
reflex,
320+
split,
318321
stm,
319322
transformers >= 0.3
323+
other-modules:
324+
Reflex.TestPlan
325+
Reflex.Plan.Reflex
326+
Reflex.Bench.Focused
320327

321328
benchmark saulzar-bench
322329
type: exitcode-stdio-1.0
@@ -327,7 +334,7 @@ benchmark saulzar-bench
327334
build-depends:
328335
base,
329336
containers >= 0.5 && < 0.7,
330-
criterion == 1.1.*,
337+
criterion >= 1.1 && < 1.6,
331338
deepseq >= 1.3 && < 1.5,
332339
dependent-map,
333340
dependent-sum,
@@ -341,6 +348,10 @@ benchmark saulzar-bench
341348
stm,
342349
time,
343350
transformers >= 0.3
351+
other-modules:
352+
Reflex.TestPlan
353+
Reflex.Plan.Reflex
354+
Reflex.Bench.Focused
344355

345356
source-repository head
346357
type: git

0 commit comments

Comments
 (0)