Skip to content

Add blname parameter to build scripts#3859

Closed
safern wants to merge 1 commit into
dotnet:masterfrom
safern:BlNameParameter
Closed

Add blname parameter to build scripts#3859
safern wants to merge 1 commit into
dotnet:masterfrom
safern:BlNameParameter

Conversation

@safern

@safern safern commented Sep 5, 2019

Copy link
Copy Markdown
Member

Currently, when the -bl flag or -ci flag is passed, there is no way to override the binary log name that is produced. The only way to do so, is to add an extra /bl:PathToBinlog, at the end of the script, where in the yaml files or elsewhere you need to hard code the path to the log dir, in order for arcade's step to publish logs to artifacts to be able to find it.

With this change, if -blname is passed, a binlog is created in the log dir, with the given name.

cc: @ViktorHofer

@safern safern requested review from chcosta and tmat September 5, 2019 17:19
@chcosta

chcosta commented Sep 5, 2019

Copy link
Copy Markdown
Member

Changes along these lines have been discussed at length in the past. It's quite often that changes like this are simply to work around an awkward or unintentional design and just lead to a more complicated underlying system. I'm not saying that is the case here, just saying that we should be intentional with changes like this.

@safern

safern commented Sep 5, 2019

Copy link
Copy Markdown
Member Author

I agree, opened the PR in order to discuss here and so that the proposed changes are clear in here. Compared to the PR opened in the past, is adding an extra argument instead of changing the current switch which would be a breaking change to do so, as if it is not a switch, you can't do: -bl as we do know, but instead would have to pass down a value. That is why a new parameter is proposed in this change.

@safern

safern commented Sep 5, 2019

Copy link
Copy Markdown
Member Author

I added my 2 cents here: #1978 (comment)

@safern

safern commented Sep 6, 2019

Copy link
Copy Markdown
Member Author

cc: @markwilkie

@tmat

tmat commented Sep 7, 2019

Copy link
Copy Markdown
Member

@safern This PR is adding a new feature to support a workaround implemented in CoreFX rather then stating what the actual problem is. The discussion of the actual problem is in a closed issue. :(

Perhaps we could first find out if we actually need the workaround and what is the best approach to address the root problem.

@safern

safern commented Sep 7, 2019

Copy link
Copy Markdown
Member Author

Perhaps we could first find out if we actually need the workaround

Well, not necessary because of the workaround, even without the need to restore the internal tools, I think we would like to still do the restore step in a separate phase than the build step because of what I stated in the other discussion:

Also, it is nice to be able to have a binlog of a -test, -restore, -build phase if repos want to split it out, when getting one binlog for all the steps together, for repos like corefx where we build 400 or so projects, they can get quite large and they're really hard to look at afterwards.

@tmat

tmat commented Sep 7, 2019

Copy link
Copy Markdown
Member

Then this should be stated as the reasoning in the PR.

@tmat

tmat commented Sep 7, 2019

Copy link
Copy Markdown
Member

Also that's a workaround for binlog viewer not being able to present larger binlog better. Perhaps that can be improved instead.

@safern

safern commented Sep 7, 2019

Copy link
Copy Markdown
Member Author

Also that's a workaround for binlog viewer not being able to present larger binlog better. Perhaps that can be improved instead.

I agree, what I don't understand is, if we're providing tooling, why repos can't have the extensibility or options in this tooling to configure the naming of the produced logs? For example, msbuild does gives you those options, of course it has a default, but you can always specify your own naming, so I don't understand why this feature has been such a discussion and a blocker. I understand that we should be conservative and understand why features are needed to keep sanity, but to me and apparently other people like @AdamYoblick and @zsd4yr brought this up, it is not only me who would like this feature.

I could just do uggly stuff like passing an extra /bl parameter and hardcoding the path in my builds, but isn't that what we're trying to avoid with providing unified tools?

@tmat

tmat commented Sep 7, 2019

Copy link
Copy Markdown
Member

@safern The issue is not primarily with naming the binlog file differently, although it breaks consistency across repos. The issue is with the reason why it is requested. You want to name the file differently to split the build. The build was designed to run all (or a subset of) the build phases in one go, so that the CI build can be easily reproduced on a dev machine the same way in all repos. If you start splitting the build into different phases, with different parameters, in different repos then then the contributor to a particular repo needs to search and understand your yaml files to see how to run that particular phase of the build in your repo. The same with artifacts - if they are named differently in different repos then I need to figure out what I'm looking for first for each repo I'm dealing with.

Besides, the reasons why running build script multiple times with different parameters have been requested in past were just workarounds for other issues that should have been addressed instead.

Comment thread eng/common/build.ps1
[string] $projects,
[string][Alias('v')]$verbosity = "minimal",
[string] $msbuildEngine = $null,
[string] $blname = $null,

@tmat tmat Sep 7, 2019

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

binaryLogName

Comment thread eng/common/build.ps1
InitializeCustomToolset

$bl = if ($binaryLog) { "/bl:" + (Join-Path $LogDir "Build.binlog") } else { "" }
$bl = if ($binaryLog) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is not a single-line if expression anymore, it would be more readable to use an if statement.

Comment thread eng/common/build.sh
echo " --configuration <value> Build configuration: 'Debug' or 'Release' (short: -c)"
echo " --verbosity <value> Msbuild verbosity: q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic] (short: -v)"
echo " --binaryLog Create MSBuild binary log (short: -bl)"
echo " --blname <value> Create MSBuild binary log with the given name"

@tmat tmat Sep 7, 2019

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

binaryLogName

@AdamYoblick

AdamYoblick commented Sep 7, 2019 via email

Copy link
Copy Markdown
Contributor

@ViktorHofer

Copy link
Copy Markdown
Member

Separating steps is something very important for the CI council, especially the restore step. Many of the repositories do an up-front restore in a separate steps to fail early and produce the right telemetry. I don't have any concerns with adding the -blName option besides the growing complexity of our build scripts.

@tmat

tmat commented Sep 7, 2019

Copy link
Copy Markdown
Member

Many of the repositories do an up-front restore in a separate steps to fail early and produce the right telemetry

Are you saying that repositories that do not do this in a separate YAML step report wrong telemetry?

@ViktorHofer

Copy link
Copy Markdown
Member

Are you saying that repositories that do not do this in a separate YAML step report wrong telemetry?

Not necessarily. The default restore step is flagged automatically but anything custom needs to be flagged additionally. Just took a look at our report, we hardly have "unknown" failures.

@tmat

tmat commented Sep 7, 2019

Copy link
Copy Markdown
Member

Then I don't understand the reasoning in this sentence:

Many of the repositories do an up-front restore in a separate steps to fail early and produce the right telemetry

@markwilkie

Copy link
Copy Markdown
Member

@chcosta - based on your involvement with CI council, do you have further insight into separating restore from build?

cc/ @Chrisboh

@chcosta

chcosta commented Sep 9, 2019

Copy link
Copy Markdown
Member

Separating restore from build or any other level of separation isn't really (IMO), high on the priority list for CI council. CI council recognizes that different repos have different challenges that may necessitate the form of that repo's build. CI council is more interested in understanding metrics about the parts that makeup a build rather than how that build is split. ie, if restore is its own step or part of the build step, isn't a particular concern; but our engineering telemetry should give us the metrics to understand our builds regardless of how they are split.

@safern

safern commented Oct 24, 2019

Copy link
Copy Markdown
Member Author

I want to ping on this thread to agree on a final decision, I think all of us have made our arguments broadly and there are some specs and conclusions here...

To summarize, the reason for the push back on this feature is because we don't want to encourage people to split or "separate" steps of the build, because that is not how arcade was designed for. We completely understand that and we agree on the purpose for that, however there are some scenarios where people might decide they want to split steps for various reasons, like reading logs on azure devops, having different logs to download and analyze separately, or others like isolate restore issues from build issues.

I think at the end people that work on those repos will do it if they think is a better experience to maintain their builds, or if it is necessary to do so in order to workaround limitations of azure devops for logging or for example in corefx, to avoid having multiple dotnet sdks in the agent, given an sdk is needed in the path to restore internal tools.

I think this feature, rather than encouraging people to do that, will avoid people from hard coding paths, passing a double parameter on CI builds (because they will eventually pass down a /bl:restore.binlog parameter to the build.cmd/sh script, which at the end will duplicate the /bl parameter, which is what winforms ended up doing and that can lead to more work "what if paths change?", "what if a variable you relied on changed?" vs having our central infrastructure providing the flexibility of renaming logs (like all other toolsets we use give), we wouldn't be hitting this ugly work arounds in multiple repos, that can lead to other issues and cause more pain.

I just want to know if this is going to be accepted given the facts I just summarized in this comment or not. If it won't be taken, it's fine, we're not blocked, but it is not ideal to do workarounds that way.

@markwilkie

Copy link
Copy Markdown
Member

To summarize, the reason for the push back on this feature is because we don't want to encourage people to split or "separate" steps of the build, because that is not how arcade was designed for.

I'm not confident this is true. Let's chat offline @safern as I want to understand this better.

@AdamYoblick

Copy link
Copy Markdown
Contributor

To summarize, the reason for the push back on this feature is because we don't want to encourage people to split or "separate" steps of the build, because that is not how arcade was designed for.

I'm not confident this is true. Let's chat offline @safern as I want to understand this better.

I think part of it is because more customization options means support and servicing becomes harder. So now you have to check the yaml to see where the logs are for the specific step that ran, etc... I get that.

But if teams are going to do it anyway with /bl: AND hardcode the path to the artifacts dir...supporting it officially seems like the lesser of two evils. Just my thoughts on it 😄

@tmat

tmat commented Oct 30, 2019

Copy link
Copy Markdown
Member

Let me suggest a solution to separation of build and restore that we can implement in Arcade. This will also demonstrate why we don't want /blname parameter in common/build.ps1.

The purpose of build.ps1 is to configure and call MSBuild function with appropriate parameters. Currently we call MSBuild once with /p:Restore=true /p:Build=true. If we agree that it's generally better to have separate binlogs for restore and build phases, we could simply call MSBuild function twice in build.ps1, each time with a different binlog name, e.g. Restore.binlog and Build.binlog. Once this is changed in Arcade all repos will get this new behavior.

We wouldn't be able to make this change if repos explicitly set the binlog name and expect it to find it under that name. I'd rather see us addressing the root of the problem then adding a new API that allows some repos to workaround the problem.

@AdamYoblick

Copy link
Copy Markdown
Contributor

Let me suggest a solution to separation of build and restore that we can implement in Arcade.

I think it's a mistake to assume the purpose of being able to pass the log name is just to separate build from restore. The purpose is to allow customers to split steps however they see fit.

In the winforms case, we wanted to split compile, unit test, integration tests, and sign/pack/publish. Azdo output looks much cleaner to us. Logs are smaller and easier to navigate.

image

In our opinion, running tests should not be lumped together with compiling, as they are two independent actions. Arcade already follows the same pattern with ToolsetRestore.binlog, this is just a logical expansion of that train of thought.

@markwilkie

Copy link
Copy Markdown
Member

I still want to chat with @safern about this so I understand better.

@alexperovich

Copy link
Copy Markdown
Member

A practical argument for allowing splitting the build into separate steps is binlog size. This build https://dev.azure.com/dnceng/internal/_build/results?buildId=422550&view=results produced a 553 MB binlog that the log viewer can't open. Four 125 MB log files would be usable and easier to analyse. With the repo consolidation happening this will become even more of a problem. Splitting Restore, Build, Test, and Publish into separate steps would make these binlog files much smaller.

@tmat

tmat commented Nov 11, 2019

Copy link
Copy Markdown
Member

@alexperovich I think it would make sense to split the binlogs to workaround KirillOsenkov/MSBuildStructuredLog#235 as I pointed out in #3859 (comment). It would be even better to actually fix KirillOsenkov/MSBuildStructuredLog#235.

@tmat

tmat commented Nov 11, 2019

Copy link
Copy Markdown
Member

Four 125 MB log files would be usable and easier to analyse.

I don't think we will get 4x125 MB though. It would be useful to try it out first. My guess is that build will still be the biggest one followed by restore.

@dougbu

dougbu commented Nov 11, 2019

Copy link
Copy Markdown
Contributor

I'm mostly w/ @tmat on this one. As long as we've got build steps that do a fair amount in a single msbuild process, the binary log will grow. Renaming that large file won't reduce its size.

But, I disagree that separating restore from build will make a significant difference, at least in ASP.NET Core repos. We just do too much.

I would generally prefer we put some work into improving one or more of

  1. … the structured log viewer's handling of large files. It seems to load the entire log in memory, likely multiple times.
  2. … the inherent compaction of binary logs -- transferring them just takes too long.
  3. … the separation of our build steps. ASP.NET Core didn't have nearly as large logs back when we separated build from test for example. Would a phased build be more efficient overall?

@tmat

tmat commented Nov 11, 2019

Copy link
Copy Markdown
Member

@dougbu

the separation of our build steps.

Could you try to experiment with what I suggested in #3859 (comment)? Just locally call MSBuild function multiple times (for build, restore and test targets) and see what the sizes of the binlogs are?

@dougbu

dougbu commented Nov 11, 2019

Copy link
Copy Markdown
Contributor

Could you try to experiment with what I suggested in #3859 (comment)?

🆗 I'll report back l8r

@dougbu

dougbu commented Nov 12, 2019

Copy link
Copy Markdown
Contributor

In 'release/3.0' branch of aspnet/AspNetCore:

command .binlog size
.\build.cmd -arch x64 -pack -all /bl:build.x64.binlog 484MB
.\build.cmd -arch x64 -restore -noBuild -all /bl:restore.x64.binlog 165MB
.\build.cmd -arch x64 -noRestore -all /bl:buildOnly.x64.binlog 307MB
.\build.cmd -arch x64 -noBuild -pack -all /bl:pack.x64.binlog 27MB

I did a git clean but did not remove dotnet before the above sequence and after the first step. So, we're comparing almost full builds from almost scratch. Didn't check with signing or publication enabled i.e. these were local builds.

@tmat

tmat commented Nov 12, 2019

Copy link
Copy Markdown
Member

@dougbu Thanks for the numbers. Seems like it'd make sense to call MSBuild separately for restore and the rest of the build. Agreed?

@dougbu

dougbu commented Nov 12, 2019

Copy link
Copy Markdown
Contributor

Agreed?

Agreed; I was surprised the restore step logged as much as it did.

Note the build part is likely larger on the CI due to signing (for Windows logs) and publication. And, unfortunately, changes to Arcade might not matter much for the AspNetCore repo because we don't make much use of eng\common\cibuild.cmd or eng\common\build.ps1 in that repo.

@tmat

tmat commented Nov 13, 2019

Copy link
Copy Markdown
Member

@nguerrera FYI

@ericstj

ericstj commented Jan 10, 2020

Copy link
Copy Markdown
Member

Is this still needed?

@AdamYoblick

Copy link
Copy Markdown
Contributor

It's not technically needed, because teams have a workaround. But the workaround involves hardcoding the path to the artifacts directory in the yaml. I feel like an officially supported way that's a little less hacky would be better.

But if people disagree, and if this workaround is acceptable from a support/servicing perspective, then ok 😄

@safern

safern commented Jan 10, 2020

Copy link
Copy Markdown
Member Author

If we agree on taking this, I'll update the PR to address feedback and fix conflicts.

@markwilkie

Copy link
Copy Markdown
Member

I finally was able to talk w/ @safern, and I have much better context.

The crux of this issue (in my view) are the implications to our value proposition of keeping things consistent and "simple". In this case, what seems to be emerging is a difference in opinion on how to deal with build "steps"... (namely, inside or outside of build)

@safern has indicated that we should know what the dotnet/runtime Arcade requirements are in a few weeks. So before we close on this, I'd like to wait a little longer and discuss this issue in context with those requirements, with the goal of addressing the underlying "cause" here and not just putting a band aid on something.

Thanks all for your continued engagement, and more soon.

@jonfortescue

Copy link
Copy Markdown
Contributor

@markwilkie @safern just pinging to see if the the dotnet/runtime have Arcade requirements clarified in the past few weeks and if we know if we're interested in taking this or not.

@markwilkie

Copy link
Copy Markdown
Member

Good ping @jonfortescue. Anything related to his emerge @safern ?

@safern

safern commented Mar 17, 2020

Copy link
Copy Markdown
Member Author

We workaround it by using the MSBuild /bl parameter and a full path to where we want the binlog to be produced. We can close this at the moment as I don't have bandwidth for this and we can revisit on adding this if needed later on.

@safern safern closed this Mar 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants