Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
safesparrow committed Nov 13, 2022
1 parent 136792b commit 01c28a3
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 36 deletions.
8 changes: 7 additions & 1 deletion src/Compiler/Driver/ParseAndCheckInputs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,12 @@ let ParseInputFilesInParallel (tcConfig: TcConfig, lexResourceManager, sourceFil

for fileName in sourceFiles do
checkInputFile tcConfig fileName



// Order files to be parsed by size (descending). The idea is to process big files first,
// so that near the end when only some nodes are still processing items, it's the smallest items,
// which should reduce the period of time where only some nodes are busy.
// This requires some empirical evidence.
let sourceFiles =
sourceFiles
|> List.mapi (fun i f -> i, f)
Expand All @@ -775,6 +780,7 @@ let ParseInputFilesInParallel (tcConfig: TcConfig, lexResourceManager, sourceFil
parseInputFileAux (tcConfig, lexResourceManager, fileName, (isLastCompiland, isExe), delayLogger, retryLocked)

idx, (input, directoryName))
// Bring back index-based order
|> List.sortBy fst
|> List.map snd
)
Expand Down
1 change: 1 addition & 0 deletions tests/ParallelTypeCheckingTests/Code/ASTVisit.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1310,6 +1310,7 @@ module TopModulesExtraction =
range) ->
let idents =
// TODO Fix this by making it similar to what happens in other places where we detect AutoOpen modules
// Currently it doesn't matter, since we don't look within modules.
if mightHaveAutoOpen synAttributeLists then
// Contents of a module that's potentially AutoOpen are available everywhere, so treat it as if it had no name ('root' module).
[| LongIdent.Empty |]
Expand Down
6 changes: 0 additions & 6 deletions tests/ParallelTypeCheckingTests/Code/Graph.fs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ module Graph =
graph.Values |> Seq.toArray |> Array.concat |> Array.except graph.Keys

addIfMissing missingNodes graph


/// Create a transitive closure of the graph
let transitiveOpt<'Node when 'Node: equality> (graph: Graph<'Node>) : Graph<'Node> =
Expand Down Expand Up @@ -107,8 +106,3 @@ module Graph =
let json = JsonConvert.SerializeObject(graph, Formatting.Indented)
printfn $"Serialising graph as JSON in {path}"
File.WriteAllText(path, json)

module FileGraph =
// open GiGraph.Dot
let makeDotFile (_path : string) (_graph : Graph<File>) : unit =
()
1 change: 1 addition & 0 deletions tests/ParallelTypeCheckingTests/Code/GraphProcessing.fs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ let combineResults
// Sort it by effectively file index.
// For some reason this is needed, otherwise gives 'missing namespace' and other errors when using the resulting state.
// Does this make sense? Should the results be foldable in any order?
// TODO Use _foldingOrderer
|> Array.sortBy (fun node -> node.Info.Item)
|> Array.filter (fun dep -> included.Contains dep.Info.Item = false)
|> Array.distinctBy (fun dep -> dep.Info.Item)
Expand Down
28 changes: 6 additions & 22 deletions tests/ParallelTypeCheckingTests/Code/ParallelTypeChecking.fs
Original file line number Diff line number Diff line change
Expand Up @@ -113,35 +113,19 @@ let CheckMultipleInputsInParallel
else
graph

let find (s : string) =
let matches (f : File) = f.Name.Contains(s, StringComparison.InvariantCultureIgnoreCase)
let files = graph.Files |> Array.filter (fun f -> matches f.File)
let d =
graph.Graph
|> Seq.filter (fun (KeyValue(f, _deps)) -> matches f)
|> Seq.map (fun (KeyValue(f, deps)) -> f, deps)
|> dict

files
|> Array.map (fun f -> f, d[f.File])

let _a = find "PostInferenceChecks.fsi"
let _b = find "ConstraintSolver"

// graph.Graph |> Graph.print

let _graphDumpPath =
graph.Graph |> Graph.print

let graphDumpPath =
let graphDumpName =
tcConfig.outputFile
|> Option.map Path.GetFileName
|> Option.defaultValue "project"

$"{graphDumpName}.deps.json"


// graph.Graph
// |> Graph.map (fun n -> n.Name)
// |> Graph.serialiseToJson graphDumpPath
graph.Graph
|> Graph.map (fun n -> n.Name)
|> Graph.serialiseToJson graphDumpPath

let _ = ctok // TODO Use
let diagnosticsLogger = DiagnosticsThreadStatics.DiagnosticsLogger
Expand Down
1 change: 1 addition & 0 deletions tests/ParallelTypeCheckingTests/Code/Types.fs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ type File =
}

member this.Name = this.AST.Name // TODO Use qualified name
// TODO Remove
member this.CodeSize = 0
member this.QualifiedName = this.AST.QualifiedName

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,14 @@ let ``1. Test sequential type-checking`` (code: Codebase) =
let config = codebaseToConfig code Method.Sequential
TestCompilerFromArgs config

/// Before running these tests, you must prepare the codebase by running the script 'FCS.prepare.ps1'
/// Before running this test, you must prepare the codebase by running the script 'FCS.prepare.ps1'
[<TestCaseSource(nameof (codebases))>]
// [<Explicit("Slow, only useful as a sanity check that the test codebase is sound and type-checks using the parallel-fs method")>]
[<Explicit("Slow, only useful as a sanity check that the test codebase is sound and type-checks using the parallel-fs method")>]
let ``2. Test parallelfs type-checking`` (code: Codebase) =
let config = codebaseToConfig code Method.ParallelCheckingOfBackedImplFiles
TestCompilerFromArgs config

/// Before running these tests, you must prepare the codebase by running the script 'FCS.prepare.ps1'
/// Before running this test, you must prepare the codebase by running the script 'FCS.prepare.ps1'
[<TestCaseSource(nameof (codebases))>]
let ``3. Test graph-based type-checking`` (code: Codebase) =
let config = codebaseToConfig code Method.Graph
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ open A


[<Test>]
let ``Another failing FCS test`` () =
let ``A top-level module with an attribute, belonging to a namespace, depends on another file that uses the same namespace`` () =
let files =
[|
"A.fsi", """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@
<HintPath>$(FSharpCoreDllPath)</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Content Include="runner.ipynb" />
</ItemGroup>

<Target Name="FakeBuild" BeforeTargets="Build">
<Message Text="Type=$(FcsReferenceType) FcsDllPath=$(FcsDllPath)" />
Expand Down

0 comments on commit 01c28a3

Please sign in to comment.