Skip to content

Commit 8ba86c1

Browse files
authored
Fix slow graph binlog (#226)
* chore: add spelling * fix: slow binlog writes for graph based builds
1 parent dc3cf9e commit 8ba86c1

File tree

3 files changed

+14
-22
lines changed

3 files changed

+14
-22
lines changed

.vscode/settings.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
"cSpell.words": [
1515
"binlog",
1616
"inheritdoc",
17+
"Ionide",
18+
"msbuild",
1719
"tfms",
1820
"vswhere",
1921
"xbuild"

src/Ionide.ProjInfo/Library.fs

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ module ProjectLoader =
532532
let pi = project.CreateProjectInstance()
533533
getTfm pi isLegacyFrameworkProj
534534

535-
let createLoggers (paths: string seq) (binaryLogs: BinaryLogGeneration) (sw: StringWriter) =
535+
let createLoggers (path: string) (binaryLogs: BinaryLogGeneration) (sw: StringWriter) =
536536
let swLogger = stringWriterLogger (sw)
537537
let msBuildLogger = msBuildToLogProvider ()
538538

@@ -541,24 +541,14 @@ module ProjectLoader =
541541
let logFileName = Path.ChangeExtension(projectFileName, ".binlog")
542542
Path.Combine(dir.FullName, logFileName)
543543

544-
match binaryLogs with
545-
| BinaryLogGeneration.Off -> [
544+
[
546545
swLogger
547546
msBuildLogger
548-
]
549-
| BinaryLogGeneration.Within dir ->
550-
let loggers =
551-
paths
552-
|> Seq.map (fun path ->
553-
let logPath = logFilePath (dir, path)
554-
Microsoft.Build.Logging.BinaryLogger(Parameters = logPath) :> ILogger
555-
)
547+
match binaryLogs with
548+
| BinaryLogGeneration.Off -> ()
549+
| BinaryLogGeneration.Within dir -> Microsoft.Build.Logging.BinaryLogger(Parameters = logFilePath (dir, path)) :> ILogger
556550

557-
[
558-
swLogger
559-
msBuildLogger
560-
yield! loggers
561-
]
551+
]
562552

563553
let getGlobalProps (tfm: string option) (globalProperties: (string * string) list) (propsSetFromParentCollection: Set<string>) =
564554
[
@@ -655,7 +645,7 @@ module ProjectLoader =
655645
let project = findOrCreateMatchingProject path projectCollection globalProperties
656646
use sw = new StringWriter()
657647

658-
let loggers = createLoggers [ path ] binaryLogs sw
648+
let loggers = createLoggers path binaryLogs sw
659649

660650
let pi = project.CreateProjectInstance()
661651
let designTimeTargets = designTimeBuildTargets isLegacyFrameworkProjFile
@@ -1224,7 +1214,7 @@ type WorkspaceLoaderViaProjectGraph private (toolsPath, ?globalProperties: (stri
12241214

12251215
let bm = BuildManager.DefaultBuildManager
12261216
use sw = new StringWriter()
1227-
let loggers = ProjectLoader.createLoggers allKnownNames binaryLogs sw
1217+
let loggers = ProjectLoader.createLoggers "graph-build" binaryLogs sw
12281218
let buildParameters = BuildParameters(Loggers = loggers)
12291219

12301220
buildParameters.ProjectLoadSettings <-

test/Ionide.ProjInfo.Tests/Tests.fs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,7 +1577,7 @@ let testFCSmapManyProjCheckCaching =
15771577
Expect.equal distinctOptionsCount projectsInLayers.Length "Mapping should reuse instances of FSharpProjectOptions and only create one per project"
15781578
)
15791579

1580-
let testSample2WithBinLog toolsPath workspaceLoader (workspaceFactory: ToolsPath -> IWorkspaceLoader) =
1580+
let testSample2WithBinLog binLogFile toolsPath workspaceLoader (workspaceFactory: ToolsPath -> IWorkspaceLoader) =
15811581
testCase
15821582
|> withLog
15831583
(sprintf "can load sample2 with bin log - %s" workspaceLoader)
@@ -1630,7 +1630,7 @@ let testSample2WithBinLog toolsPath workspaceLoader (workspaceFactory: ToolsPath
16301630

16311631
let blPath =
16321632
projDir
1633-
/ "n1.binlog"
1633+
/ binLogFile
16341634

16351635
let blExists = File.Exists blPath
16361636

@@ -2364,8 +2364,8 @@ let tests toolsPath =
23642364
loadProjfileFromDiskTests toolsPath "WorkspaceLoaderViaProjectGraph" WorkspaceLoaderViaProjectGraph.Create
23652365

23662366
//Binlog test
2367-
testSample2WithBinLog toolsPath "WorkspaceLoader" WorkspaceLoader.Create
2368-
testSample2WithBinLog toolsPath "WorkspaceLoaderViaProjectGraph" WorkspaceLoaderViaProjectGraph.Create
2367+
testSample2WithBinLog "n1.binlog" toolsPath "WorkspaceLoader" WorkspaceLoader.Create
2368+
testSample2WithBinLog "graph-build.binlog" toolsPath "WorkspaceLoaderViaProjectGraph" WorkspaceLoaderViaProjectGraph.Create
23692369
test "can get runtimes" {
23702370
let runtimes =
23712371
SdkDiscovery.runtimes (

0 commit comments

Comments
 (0)