Repository navigation
Fix cabal issue 7557: don’t run benchmarks in parallel or with the build #12407
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
Open
ulysses4ever
wants to merge
5
commits into
haskell:master
Choose a base branch
from
ulysses4ever:claude/cabal-issue-7557-m1znrj
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+251
−18
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0a1e138
Run benchmarks one at a time in `cabal bench` (#7557)
claude 3f154f4
Run benchmarks only once everything is built (#7557)
claude c7512bf
Describe plan units accurately in Note [Running benchmarks]
claude 9e82afc
Use an IORef for the deferred benchmarks
claude d013dd5
Address review: simplify runDeferredBenchmarks, mark changelog signif…
ulysses4ever File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
cabal-testsuite/PackageTests/NewBuild/CmdBench/Sequential/cabal.project
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| packages: pkg-a pkg-b |
21 changes: 21 additions & 0 deletions
21
cabal-testsuite/PackageTests/NewBuild/CmdBench/Sequential/cabal.test.hs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import Test.Cabal.Prelude | ||
|
|
||
| import Data.List (isInfixOf, isPrefixOf, isSuffixOf) | ||
|
|
||
| -- #7557: benchmarks are only run once everything is built, and one at a time, | ||
| -- even when building in parallel. | ||
| main = cabalTest $ | ||
| -- Parallel flag means output of this test is nondeterministic | ||
| recordMode DoNotRecord $ do | ||
| -- Each benchmark fails if another one is running at the same time, | ||
| -- see Bench.hs. | ||
| res <- cabal' "v2-bench" ["-j3", "all"] | ||
| let isBuildStep l = | ||
| any (`isPrefixOf` l) ["Configuring ", "Preprocessing ", "Building ", "Linking "] | ||
| || any (`isInfixOf` l) ["] Compiling ", "] Linking "] | ||
| isBenchmarkRun l = "Benchmark " `isPrefixOf` l && ": RUNNING..." `isSuffixOf` l | ||
| output = lines (filter (/= '\r') (resultOutput res)) | ||
| afterFirstRun = dropWhile (not . isBenchmarkRun) output | ||
| assertEqual "Number of benchmarks run" 3 (length (filter isBenchmarkRun output)) | ||
| assertBool "Something was built after the first benchmark started" $ | ||
| not (any isBuildStep afterFirstRun) |
18 changes: 18 additions & 0 deletions
18
cabal-testsuite/PackageTests/NewBuild/CmdBench/Sequential/pkg-a/Bench.hs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| import Control.Concurrent (threadDelay) | ||
| import System.Directory (createDirectory, removeDirectory) | ||
| import System.Exit (die) | ||
| import System.IO.Error (catchIOError, isAlreadyExistsError) | ||
|
|
||
| -- All the benchmarks of this test, in both packages, claim the same marker | ||
| -- directory while they run. Creating it fails if it already exists, that is, | ||
| -- if another benchmark is running at the same time. | ||
| main :: IO () | ||
| main = do | ||
| createDirectory marker `catchIOError` \e -> | ||
| if isAlreadyExistsError e | ||
| then die "Another benchmark is running at the same time" | ||
| else ioError e | ||
| threadDelay 2000000 | ||
| removeDirectory marker | ||
| where | ||
| marker = "../benchmark-running" |
16 changes: 16 additions & 0 deletions
16
cabal-testsuite/PackageTests/NewBuild/CmdBench/Sequential/pkg-a/pkg-a.cabal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| cabal-version: 3.0 | ||
| name: pkg-a | ||
| version: 1.0 | ||
| build-type: Simple | ||
|
|
||
| benchmark a1 | ||
| type: exitcode-stdio-1.0 | ||
| main-is: Bench.hs | ||
| build-depends: base, directory | ||
| default-language: Haskell2010 | ||
|
|
||
| benchmark a2 | ||
| type: exitcode-stdio-1.0 | ||
| main-is: Bench.hs | ||
| build-depends: base, directory | ||
| default-language: Haskell2010 |
18 changes: 18 additions & 0 deletions
18
cabal-testsuite/PackageTests/NewBuild/CmdBench/Sequential/pkg-b/Bench.hs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| import Control.Concurrent (threadDelay) | ||
| import System.Directory (createDirectory, removeDirectory) | ||
| import System.Exit (die) | ||
| import System.IO.Error (catchIOError, isAlreadyExistsError) | ||
|
|
||
| -- All the benchmarks of this test, in both packages, claim the same marker | ||
| -- directory while they run. Creating it fails if it already exists, that is, | ||
| -- if another benchmark is running at the same time. | ||
| main :: IO () | ||
| main = do | ||
| createDirectory marker `catchIOError` \e -> | ||
| if isAlreadyExistsError e | ||
| then die "Another benchmark is running at the same time" | ||
| else ioError e | ||
| threadDelay 2000000 | ||
| removeDirectory marker | ||
| where | ||
| marker = "../benchmark-running" |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.