Skip to content

Commit

Permalink
Fix slow graph binlog (#226)
Browse files Browse the repository at this point in the history
* chore: add spelling

* fix: slow binlog writes for graph based builds
  • Loading branch information
TheAngryByrd authored Feb 18, 2025
1 parent dc3cf9e commit 8ba86c1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 22 deletions.
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
"cSpell.words": [
"binlog",
"inheritdoc",
"Ionide",
"msbuild",
"tfms",
"vswhere",
"xbuild"
Expand Down
26 changes: 8 additions & 18 deletions src/Ionide.ProjInfo/Library.fs
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ module ProjectLoader =
let pi = project.CreateProjectInstance()
getTfm pi isLegacyFrameworkProj

let createLoggers (paths: string seq) (binaryLogs: BinaryLogGeneration) (sw: StringWriter) =
let createLoggers (path: string) (binaryLogs: BinaryLogGeneration) (sw: StringWriter) =
let swLogger = stringWriterLogger (sw)
let msBuildLogger = msBuildToLogProvider ()

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

match binaryLogs with
| BinaryLogGeneration.Off -> [
[
swLogger
msBuildLogger
]
| BinaryLogGeneration.Within dir ->
let loggers =
paths
|> Seq.map (fun path ->
let logPath = logFilePath (dir, path)
Microsoft.Build.Logging.BinaryLogger(Parameters = logPath) :> ILogger
)
match binaryLogs with
| BinaryLogGeneration.Off -> ()
| BinaryLogGeneration.Within dir -> Microsoft.Build.Logging.BinaryLogger(Parameters = logFilePath (dir, path)) :> ILogger

[
swLogger
msBuildLogger
yield! loggers
]
]

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

let loggers = createLoggers [ path ] binaryLogs sw
let loggers = createLoggers path binaryLogs sw

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

let bm = BuildManager.DefaultBuildManager
use sw = new StringWriter()
let loggers = ProjectLoader.createLoggers allKnownNames binaryLogs sw
let loggers = ProjectLoader.createLoggers "graph-build" binaryLogs sw
let buildParameters = BuildParameters(Loggers = loggers)

buildParameters.ProjectLoadSettings <-
Expand Down
8 changes: 4 additions & 4 deletions test/Ionide.ProjInfo.Tests/Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1577,7 +1577,7 @@ let testFCSmapManyProjCheckCaching =
Expect.equal distinctOptionsCount projectsInLayers.Length "Mapping should reuse instances of FSharpProjectOptions and only create one per project"
)

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

let blPath =
projDir
/ "n1.binlog"
/ binLogFile

let blExists = File.Exists blPath

Expand Down Expand Up @@ -2364,8 +2364,8 @@ let tests toolsPath =
loadProjfileFromDiskTests toolsPath "WorkspaceLoaderViaProjectGraph" WorkspaceLoaderViaProjectGraph.Create

//Binlog test
testSample2WithBinLog toolsPath "WorkspaceLoader" WorkspaceLoader.Create
testSample2WithBinLog toolsPath "WorkspaceLoaderViaProjectGraph" WorkspaceLoaderViaProjectGraph.Create
testSample2WithBinLog "n1.binlog" toolsPath "WorkspaceLoader" WorkspaceLoader.Create
testSample2WithBinLog "graph-build.binlog" toolsPath "WorkspaceLoaderViaProjectGraph" WorkspaceLoaderViaProjectGraph.Create
test "can get runtimes" {
let runtimes =
SdkDiscovery.runtimes (
Expand Down

0 comments on commit 8ba86c1

Please sign in to comment.