@@ -177,6 +177,8 @@ data MkBuildRules buildSystem = MkBuildRules
177
177
findGhc :: buildSystem -> FilePath -> IO FilePath
178
178
-- | Name of the binary produced by 'buildProject'
179
179
, executableName :: String
180
+ -- | An action that captures the source dependencies, used for the HEAD build
181
+ , projectDepends :: Action ()
180
182
-- | Build the project found in the cwd and save the build artifacts in the output folder
181
183
, buildProject :: buildSystem
182
184
-> [CmdOption ]
@@ -204,9 +206,8 @@ buildRules build MkBuildRules{..} = do
204
206
, build -/- " binaries/HEAD/ghc.path"
205
207
]
206
208
&%> \ [out, ghcpath] -> do
209
+ projectDepends
207
210
liftIO $ createDirectoryIfMissing True $ dropFileName out
208
- -- TOOD more precise dependency tracking
209
- need =<< getDirectoryFiles " ." [" //*.hs" , " *.cabal" ]
210
211
buildSystem <- askOracle $ GetBuildSystem ()
211
212
buildProject buildSystem [Cwd " ." ] (takeDirectory out)
212
213
ghcLoc <- liftIO $ findGhc buildSystem " ."
@@ -233,6 +234,8 @@ data MkBenchRules buildSystem example = forall setup. MkBenchRules
233
234
setupProject :: Action setup
234
235
-- | An action that invokes the executable to run the benchmark
235
236
, benchProject :: setup -> buildSystem -> [CmdOption ] -> BenchProject example -> Action ()
237
+ -- | An action that performs any necessary warmup. Will only be invoked once
238
+ , warmupProject :: buildSystem -> FilePath -> [CmdOption ] -> example -> Action ()
236
239
-- | Name of the executable to benchmark. Should match the one used to 'MkBuildRules'
237
240
, executableName :: String
238
241
}
@@ -262,13 +265,34 @@ benchRules :: RuleResultForExample example => FilePattern -> MkBenchRules BuildS
262
265
benchRules build MkBenchRules {.. } = do
263
266
264
267
benchResource <- newResource " ghcide-bench" 1
268
+ -- warmup an example
269
+ build -/- " binaries/*/*.warmup" %> \ out -> do
270
+ let [_, _, ver, exampleName] = splitDirectories (dropExtension out)
271
+ let exePath = build </> " binaries" </> ver </> executableName
272
+ ghcPath = build </> " binaries" </> ver </> " ghc.path"
273
+ need [exePath, ghcPath]
274
+ buildSystem <- askOracle $ GetBuildSystem ()
275
+ example <- fromMaybe (error $ " Unknown example " <> exampleName)
276
+ <$> askOracle (GetExample exampleName)
277
+ let exeExtraArgs = []
278
+ outcsv = " "
279
+ experiment = Escaped " hover"
280
+ withResource benchResource 1 $ warmupProject buildSystem exePath
281
+ [ EchoStdout False ,
282
+ FileStdout out,
283
+ RemEnv " NIX_GHC_LIBDIR" ,
284
+ RemEnv " GHC_PACKAGE_PATH" ,
285
+ AddPath [takeDirectory ghcPath, " ." ] []
286
+ ]
287
+ example
265
288
-- run an experiment
266
289
priority 0 $
267
290
[ build -/- " */*/*/*.csv" ,
268
291
build -/- " */*/*/*.gcStats.log" ,
269
292
build -/- " */*/*/*.output.log" ,
293
+ build -/- " */*/*/*.eventlog" ,
270
294
build -/- " */*/*/*.hp"
271
- ] &%> \ [outcsv, outGc, outLog, outHp] -> do
295
+ ] &%> \ [outcsv, outGc, outLog, outEventlog, outHp] -> do
272
296
let [_, flavour, exampleName, ver, exp ] = splitDirectories outcsv
273
297
prof = fromMaybe (error $ " Not a valid profiling mode: " <> flavour) $ profilingP flavour
274
298
example <- fromMaybe (error $ " Unknown example " <> exampleName)
@@ -279,6 +303,7 @@ benchRules build MkBenchRules{..} = do
279
303
let exePath = build </> " binaries" </> ver </> executableName
280
304
exeExtraArgs =
281
305
[ " +RTS"
306
+ , " -l-au"
282
307
, " -S" <> outGc]
283
308
++ concat
284
309
[[ " -h"
@@ -287,8 +312,9 @@ benchRules build MkBenchRules{..} = do
287
312
| CheapHeapProfiling i <- [prof]]
288
313
++ [" -RTS" ]
289
314
ghcPath = build </> " binaries" </> ver </> " ghc.path"
315
+ warmupPath = build </> " binaries" </> ver </> exampleName <.> " warmup"
290
316
experiment = Escaped $ dropExtension exp
291
- need [exePath, ghcPath]
317
+ need [exePath, ghcPath, warmupPath ]
292
318
ghcPath <- readFile' ghcPath
293
319
withResource benchResource 1 $ do
294
320
benchProject setupRes buildSystem
@@ -299,6 +325,7 @@ benchRules build MkBenchRules{..} = do
299
325
AddPath [takeDirectory ghcPath, " ." ] []
300
326
]
301
327
BenchProject {.. }
328
+ liftIO $ renameFile " ghcide.eventlog" outEventlog
302
329
liftIO $ case prof of
303
330
CheapHeapProfiling {} -> renameFile " ghcide.hp" outHp
304
331
NoProfiling -> writeFile outHp dummyHp
0 commit comments