Repository navigation
Closed
Labels
Description
Edit: See #27374 (comment) for investigation
Description
qiao@X64:~/work_qiao/dotnet-runtime-loongarch/.dotnet$ ./dotnet --info
.NET SDK (反映任何 global.json):
Version: 6.0.108
Commit: 4e3a463d2b
运行时环境:
OS Name: debian
OS Version: 10
OS Platform: Linux
RID: debian.10-x64
Base Path: /home/qiao/work_qiao/dotnet-runtime-loongarch/.dotnet/sdk/6.0.108/
global.json file:
/home/qiao/work_qiao/dotnet-runtime-loongarch/global.json
Host:
Version: 6.0.8
Architecture: x64
Commit: 55fb7ef977
.NET SDKs installed:
6.0.108 [/home/qiao/work_qiao/dotnet-runtime-loongarch/.dotnet/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.8 [/home/qiao/work_qiao/dotnet-runtime-loongarch/.dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.8 [/home/qiao/work_qiao/dotnet-runtime-loongarch/.dotnet/shared/Microsoft.NETCore.App]
Download .NET:
https://aka.ms/dotnet-download
Learn about .NET Runtimes and SDKs:
https://aka.ms/dotnet/runtimes-sdk-info
----------------------------------
qiao@X64:~/work_qiao/dotnet-runtime-loongarch/.dotnet$ time ./dotnet build --help
Description:
.NET 生成器
Usage:
dotnet [options] build [<PROJECT | SOLUTION>...]
Arguments:
<PROJECT | SOLUTION> 要操作的项目或解决方案文件。如果没有指定文件,则命令将在当前目录里搜索一个文件。
Options:
--use-current-runtime 将当前运行时用作目标运行时。
-f, --framework <FRAMEWORK> 要生成的目标框架。必须在项目文件中指定目标框架。
-c, --configuration <CONFIGURATION> 用于生成项目的配置。大多数项目的默认值是 "Debug"。
-r, --runtime <RUNTIME_IDENTIFIER> 要生成的目标运行时。
--version-suffix <VERSION_SUFFIX> 设置生成项目时使用的 $(VersionSuffix) 属性的值。
--no-restore 生成前请勿还原项目。
--interactive 允许命令停止和等待用户输入或操作(例如,用以完成身份验证)。
-v, --verbosity <LEVEL> 设置 MSBuild 详细程度。允许值为 q[uiet]、m[inimal]、n[ormal]、d[etailed] 和 diag[nostic]。
--debug
-o, --output <OUTPUT_DIR> 要放置生成项目的输出目录。
--no-incremental 请勿使用增量生成。
--no-dependencies 请勿生成项目到项目引用,仅生成指定项目。
--nologo 不显示启动版权标志或版权消息。
--sc, --self-contained 随应用程序一起发布 .NET 运行时,这样就不需要在目标计算机上安装运行时。
如果指定了运行时标识符,则默认值为 "true"。
--no-self-contained 将应用程序发布为依赖框架的应用程序。目标计算机上必须安装兼容的 .NET 运行时才能运行该应用程序。
-a, --arch <arch> 目标体系结构。
--os <os> 目标操作系统。
-?, -h, --help 显示命令行帮助。
real 0m0.520s
user 0m0.413s
sys 0m0.028swhile the .NET7 is slower,
qiao@X64:~/work_qiao/runtime$ .dotnet/dotnet --info
.NET SDK (反映任何 global.json):
Version: 7.0.100-preview.7.22377.5
Commit: ba310d9309
运行时环境:
OS Name: debian
OS Version: 10
OS Platform: Linux
RID: debian.10-x64
Base Path: /home/qiao/work_qiao/runtime/.dotnet/sdk/7.0.100-preview.7.22377.5/
Host:
Version: 7.0.0-preview.7.22375.6
Architecture: x64
Commit: eecb028078
.NET SDKs installed:
7.0.100-preview.7.22377.5 [/home/qiao/work_qiao/runtime/.dotnet/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 7.0.0-preview.7.22376.6 [/home/qiao/work_qiao/runtime/.dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 7.0.0-preview.7.22375.6 [/home/qiao/work_qiao/runtime/.dotnet/shared/Microsoft.NETCore.App]
Other architectures found:
None
Environment variables:
Not set
global.json file:
/home/qiao/work_qiao/runtime/global.json
Learn more:
https://aka.ms/dotnet/info
Download .NET:
https://aka.ms/dotnet/download
-----------------------------------------
qiao@X64:~/work_qiao/runtime$ time .dotnet/dotnet build --help
Description:
.NET 生成器
Usage:
dotnet build [<PROJECT | SOLUTION>...] [options]
Arguments:
<PROJECT | SOLUTION> 要操作的项目或解决方案文件。如果没有指定文件,则命令将在当前目录里搜索一个文件。
Options:
--use-current-runtime 将当前运行时用作目标运行时。
-f, --framework <FRAMEWORK> 要生成的目标框架。必须在项目文件中指定目标框架。
-c, --configuration <CONFIGURATION> 用于生成项目的配置。大多数项目的默认值是 "Debug"。
-r, --runtime <RUNTIME_IDENTIFIER> 要生成的目标运行时。
--version-suffix <VERSION_SUFFIX> 设置生成项目时使用的 $(VersionSuffix) 属性的值。
--no-restore 生成前请勿还原项目。
--interactive 允许命令停止和等待用户输入或操作(例如,用以完成身份验证)。
-v, --verbosity <LEVEL> 设置 MSBuild 详细程度。允许值为 q[uiet]、m[inimal]、n[ormal]、d[etailed] 和 diag[nostic]。
--debug
-o, --output <OUTPUT_DIR> 要放置生成项目的输出目录。
--no-incremental 请勿使用增量生成。
--no-dependencies 请勿生成项目到项目引用,仅生成指定项目。
--nologo 不显示启动版权标志或版权消息。
--sc, --self-contained 随应用程序一起发布 .NET 运行时,这样就不需要在目标计算机上安装运行时。
如果指定了运行时标识符,则默认值为 "true"。
--no-self-contained 将应用程序发布为依赖框架的应用程序。目标计算机上必须安装兼容的 .NET 运行时才能运行该应用程序。
-a, --arch <arch> 目标体系结构。
--os <os> 目标操作系统。
--disable-build-servers Force the command to ignore any persistent build servers.
-?, -h, --help 显示命令行帮助。
real 1m15.714s
user 1m11.285s
sys 0m7.549s
Activity
shushanhf commentedon Aug 19, 2022
There is a very insteresting thing:
If entered the
.dotnetdirectory, it will be very fast.While if outside of the
.dotnetdirectory, it will be very slow.shushanhf commentedon Aug 19, 2022
This only happens within the
runtimedirectory while includes theglobal.json.If deleting the
global.json, it will be normal.elinor-fung commentedon Aug 19, 2022
@shushanhf do you see the same slower execution with commands like
dotnet --info(ordotnet --helpordotnet new --help) or is it onlydotnet build --help? From the runtime host side, we look at theglobal.jsonthe same way in all those cases, so I'm wondering if there's something with the SDK command handling itself.Could you also share the contents of your
global.json?I don't think we ended up changing how we handle global.json in .NET 7 (although there were definitely discussions about improvements). We did disable multi-level lookup, but that was Windows-only behaviour to begin with.
shushanhf commentedon Aug 20, 2022
This file is within the
runtime, and both runtime6.0 and runtime7.0 have this interesting thing.The
dotnet --helpanddotnet new --helpare normal, thedotnet build --helpanddotnet run --helphad this interesting thing.#27374
You must be under the root directory of the
runtimeproject and you had downloaded the SDK, and then run the commandtime .dotnet/dotnet build --help.If you changed the directory, for example
cd ..which changed to the parent directory, the commandtime ./runtime/.dotnet/dotnet build --helpis very fast.elinor-fung commentedon Aug 23, 2022
Ah, I missed that you were seeing this in both .NET 6 and 7.
That definitely makes me think there is something with the SDK command handling itself.
Could you try setting the environment variables:
@marcpopMSFT @baronfel Is there a better/recommended way and instructions for collecting information for SDK command perf?
I tried to make a simple repro, but did not observe this behaviour. This is my understanding of the scenario - please let me know if I have something wrong.
Created a directory with this layout:
Where the .NET SDK is a downloaded/unzipped .NET 7 Preview 7 and
global.jsonis copied from https://github.com/dotnet/runtime/blob/main/global.json.dotnetdirectoryglobal.json/.dotnetglobal.jsonand run from the same directory, they are all normal.elinor-fung commentedon Aug 23, 2022
Okay - I stopped trying to create a stripped down repro. I am able to repro this using a full clone of the runtime repo. Looks like it needs to be a combination of the
msbuild-sdksspecified in theglobal.jsonand other files in the repo.elinor-fung commentedon Aug 23, 2022
This is due to some SDK commands doing a project evaluation - including resolving msbuild SDKs based on a
global.json- just to print their help. When the command was run from the.dotnetdirectory, there is no project in the working directory to evaluate, so it was fine.It is triggered by the command completion for the framework option:
sdk/src/Cli/dotnet/commands/dotnet-complete/Complete.cs
Lines 22 to 33 in 7e62e8d
Running
--helpfor any command using that would hit this issue, including:Call stack:
Moving to dotnet/sdk
[-]`dotnet build --help` is slower than .NET6[/-][+]`dotnet build --help` results in project evaluation and msbuild SDK resolution[/+]KalleOlaviNiemitalo commentedon Oct 11, 2022
.NET SDK sets ArgumentHelpName = "FRAMEWORK", which prevents --help from displaying the completions:
sdk/src/Cli/dotnet/CommonOptions.cs
Lines 43 to 51 in ac00abe
sdk/src/Cli/dotnet/CommonLocalizableStrings.resx
Lines 653 to 655 in ac00abe
HelpBuilder.Default.GetArgumentUsageLabel wastes time by querying the completions even though it will ignore them in this case. That could be fixed in dotnet/command-line-api, by moving the
var completionsinitialization to anelsebranch:https://github.com/dotnet/command-line-api/blob/209b724a3c843253d3071e8348c353b297b0b8b5/src/System.CommandLine/Help/HelpBuilder.Default.cs#L66-L87
This scenario was not optimized in dotnet/command-line-api#1367 when HelpBuilder was changed to display Argument.HelpName. Filed as dotnet/command-line-api#2038.
KalleOlaviNiemitalo commentedon Sep 2, 2023
This has been fixed in .NET SDK 8.0.100-preview.7.23376.3. When I run
dotnet build --helpin a project directory, Process Monitor does not show access to any paths that contain "Microsoft.NET.Sdk". In contrast, when I run justdotnet build, Process Monitor shows access to those paths.I think the fix came in as part of #33157, which was merged between v8.0.100-preview.6.23330.7 and v8.0.100-preview.7.23376.5. That PR upgraded System.CommandLine from 2.0.0-beta4.22564.1 (commit 8374d5fca634a93458c84414b1604c12f765d1ab) to 2.0.0-beta4.23307.1 (commit 02fe27cd6a9b001c8feb7938e6ef4b3799745759). The diff between those includes dotnet/command-line-api#2073, which fixed dotnet/command-line-api#2038.
Please close, unless the team intends to backport.