Repository navigation
Improve jitutils - #103
Improve jitutils#103
Conversation
|
@russellhadley @JosephTremoulet @dotnet/jit-contrib PTAL |
| "base": "checked_osx-1526", | ||
| "diff": "/Users/russellhadley/Work/dotnet/coreclr/bin/Product/OSX.x64.Checked", | ||
| "analyze": "true", | ||
| "frameworksonly": "true", |
There was a problem hiding this comment.
There's no longer an option called frameworksonly, right?
There was a problem hiding this comment.
Likewise for analyze
| ### Installing new tools | ||
|
|
||
| The jit-diff command `install` will download and install a new tool to the default location | ||
| and update the config.json so it can be found. |
There was a problem hiding this comment.
Didn't the commit message say you removed this?
There was a problem hiding this comment.
No; install still exists. Honestly, though, I've never used it (successfully).
There was a problem hiding this comment.
I've used install successfully - this is a time saver for me so I'm keen to keep it.
There was a problem hiding this comment.
Nobody has suggested removing it.
| Only one of `--tests` or `--benchmarks` can be specified. | ||
|
|
||
| If `--tests` or `--benchmarks` is specified, you must also specify `--test_root` so the tool knows | ||
| where to find the test tree you wish to use. |
There was a problem hiding this comment.
Does --test_root not have a default?
There was a problem hiding this comment.
It does (that was a late change). I'll update the wording.
|
|
||
| ``` | ||
| c:\gh\coreclr> jit-diff diff -o c:\diffs -t 5 -a -f --core_root c:\gh\coreclr\bin\tests\Windows_NT.x86.checked\Tests\Core_Root -b e:\gh\coreclr2\bin\Product\Windows_NT.x86.checked -d c:\gh\coreclr\bin\Product\Windows_NT.x86.checked | ||
| c:\gh\coreclr> jit-diff diff --output c:\diffs --corelib --core_root c:\gh\coreclr\bin\tests\Windows_NT.x64.checked\Tests\Core_Root --base e:\gh\coreclr2\bin\Product\Windows_NT.x64.checked --diff c:\gh\coreclr\bin\Product\Windows_NT.x64.checked |
There was a problem hiding this comment.
Should use release for core_root
| * If jit-diff is invoked with the current directory within the dotnet/coreclr repo, then the root of | ||
| this repo serves to find the diff compiler and `CORE_ROOT` directory. (Note that we have no reasonable | ||
| default for determining what the baseline toolset or repo is. This is specified with the `--base_root` argument.) | ||
| * The default output directory is `<repo_root>\diffs` (in this case, c:\gh\coreclr\diffs). |
There was a problem hiding this comment.
Not a fan of spewing output into the source tree. Does coreclr's .gitignore ignore this?
There was a problem hiding this comment.
We could change .gitignore. Or, you could pass --output or set it in a config.json.
Do you have an alternative suggestion for a default?
There was a problem hiding this comment.
My inclination is to make --output a required parameter. Failing that, I don't see what to do other than put diffs in .gitignore or maybe default to obj/diffs or bin/diffs if one of those is appropriate.
There was a problem hiding this comment.
I like the idea of (by default) putting them in bin/diffs; that directory is already .gitignore'd.
There was a problem hiding this comment.
I don't want to have any required parameters if possible.
| if ((_platformPath == null) || (_basePath == null) || (_diffPath == null) || ((_testPath == null) && needTestTree)) | ||
| { | ||
| // Try all combinations of build and architecture to find one that has both a Core_Root | ||
| // and, if necessary, base and diff builds and tests. |
There was a problem hiding this comment.
core_root and test_root should only ever default to release. If the person running the tool hasn't built the release tree, better to tell them they need to than have them run diffs on a different build flavor.
There was a problem hiding this comment.
I'm not sure I agree. I never use release. And the tool does tell you when it uses a default, what it is.
There was a problem hiding this comment.
And the tool does tell you when it uses a default, what it is.
Sure, but that will be buried by the output spew, hence the desire for a prompt before spewing.
| { | ||
| Console.WriteLine("No platform mapping!"); | ||
| _moniker = "bogus"; | ||
| buildList = new List<string> { "checked", "debug" }; |
There was a problem hiding this comment.
Defaulting build flavors for any of these seems dicey. I for one almost always have out-of-date trees built of one flavor or another. I'd go so far as to say we should print out what we're picking and prompt for user input before continuing (maybe with an explicit --quiet flag to opt out).
|
|
||
| if ((_platformPath == null) && (_diffRoot != null)) | ||
| { | ||
| tryPlatformPath = Path.Combine(_diffRoot, "bin", "tests", buildDirName, "Tests", "Core_Root"); |
There was a problem hiding this comment.
On Linux, I've always pointed --core_root to the overlay directory I created. I think you've mentioned in the docs above that running runtests.sh GenerateLayoutOnly will populate this Core_Root with the right set of stuff that this will work on Linux, but wanted to make sure I'm getting that right -- is that what you're saying/expecting, that this formula works on all supported platforms assuming that the dev has done a GenerateLayoutOnly runtests?
There was a problem hiding this comment.
That's my expectation.
| StartDasmWork(args); | ||
| } | ||
|
|
||
| // Returns a count of the number of failures. |
| } | ||
| } | ||
|
|
||
| private string GetRepoRoot() |
There was a problem hiding this comment.
I wonder if we shouldn't have a jitutils.utility.dll...
There was a problem hiding this comment.
I'd prefer to just have a shared utils.cs file statically linked in. But yes, there is too much code duplication now.
|
|
||
| To simplify this more, create a dotnet/coreclr repo clone that you will always use for baselines. | ||
| Create a configuration file that specifies your baseline root directory, specifying a `base_root` | ||
| default. See the document [configuring defaults](config.md) for details. |
There was a problem hiding this comment.
I also grab baseline jits via cijobs. Additionally there are dasm results for baselines that can be grabbed even speeding this up more. I think we should make the default path more inline with reusing what's already been built/computed in the cloud.
| ### Installing new tools | ||
|
|
||
| The jit-diff command `install` will download and install a new tool to the default location | ||
| and update the config.json so it can be found. |
There was a problem hiding this comment.
I've used install successfully - this is a time saver for me so I'm keen to keep it.
|
|
||
| The defaults are: | ||
| * If jit-diff is invoked with the current directory within the dotnet/coreclr repo, then the root of | ||
| this repo serves to find the diff compiler and `CORE_ROOT` directory. (Note that we have no reasonable |
There was a problem hiding this comment.
Just to add a wrinkle here, I typically run from outside the repo structure and provide a standalone output dir with tools in it.
| * The default output directory is `<repo_root>\diffs` (in this case, c:\gh\coreclr\diffs). | ||
| * The default diff architecture is x64. If this isn't found, x86 is tried. | ||
| * The default diff build flavor is checked. If this isn't found, debug is tried. | ||
| * By default, diffs are done using System.Private.CoreLib.dll. (That is, `--corelib` is the default.) |
| This supports a scenario like the following: | ||
|
|
||
| * Build base CoreCLR | ||
| * Produce baseline diffs by invoking the tool with '--base' |
There was a problem hiding this comment.
I think I'm still leery about putting non config file defaults baked into the tool. Just in the 4 people that have commented we've seen enough variation to make this a hard nut to crack. I'm worried that we're inviting forking the tools to support different peoples defaults.
|
@JosephTremoulet @russellhadley I've updated jit-diff with new argument rules, as discussed in the PR comments. I've updated all the help, as well as adding a bunch of examples to the tool usage message. E.g., you must now specify PTAL. Also, I would appreciate it if you also pulled this down and tried it on your scenarios to ensure that it works for those, which are different from mine. cc @dotnet/jit-contrib |
|
I just noticed the -lastSuccessful flag being removed. What happened? It broke once before when the Jenkins REST API output changed. Was it that again? (I find it convenient to grab the last successful build as a baseline and then branch from there for working since I'm in a good state then by construction) |
|
I figured out the mystery with why install doesn't work. The dotnet moniker for Windows changed and no longer matches the directory name I was looking for in what Jenkins produces for the job. There's some missing defensive code that needs to get added. This can be fixed by using the new GetBuildOS method, but this highlights that there's duplication between the SetRID logic and GetBuildOS that should be reconciled. |
|
I've fixed the install command and installed my base tool set and have everything set in the config file but I'm having a lot of trouble running the baseline set: |
|
More details And here's my config file: |
JosephTremoulet
left a comment
There was a problem hiding this comment.
Thanks for making the updates. I have some fairly minor inline comments. Also wanted to (re-)mention a few higher-level things, none of which I think need any further changes in this PR, but which I'm curious your (and others') opinion on and if we should file follow-up issues:
- I worry about warnings getting buried by the output spew. I had suggested earlier a prompt after the warnings and before generating dasm, but there are a variety of other options, like squelching the output spew, or sending it to a log file instead of the console, or repeating any warnings at the end of the run...
- I worry about the strategy of iterating through architectures and build flavors until we can find one that has enough built artifacts. It would work fine for devs who typically only have one flavor built, but I know in my case I typically have only one or two flavors recently built, and have stale artifacts of the other flavors, and I'd guess I'm not alone in that. Printing the defaults we've found (and warning if it's non-release compilands) is great, but still seems easy to overlook and then waste time/effort tracking down diffs or lack of diffs due to running the wrong compiler. I'd love to build in a bit more protection against that, but I don't have any great ideas. We could check if there are multiple arch/flavor combinations that have everything built, and warn if there are multiple? Or warn if the selected default doesn't have the latest timestamp? Or default to the one with the latest timestamp instead of the first one found?
- We should do something to share code that's copied across different jitutils.
| build the repo, publish the resulting binaries to a common "bin" directory, and place them on the path. | ||
| This can be run to set up the developer in one shot. | ||
|
|
||
| To build jitutils not using the bootstrap script, run: `build.{cmd,sh}`. By |
There was a problem hiding this comment.
You need to have cli (with minimum version xxx.yyy) installed and run dotnet restore before you can run build.{cmd,sh}.
| 2. `--corelib` -- generate diffs using System.Private.CoreLib.dll. | ||
| 3. `--core_root` -- specify the `CORE_ROOT` directory (the "test layout"). Used to specify to crossgen | ||
| where the platform assemblies are. Also, used as the directory where framework assemblies such as | ||
| System.Private.CoreLib.dll can be found for the purpose of using them to generate dasm. |
There was a problem hiding this comment.
I think it's been said that System.Private.CoreLib.dll is special and actually gets pulled from wherever the running crossgen.exe is. Maybe change the example to System.Runtime.dll or something.
| The defaults are: | ||
| * If jit-diff is invoked with the current directory within the dotnet/coreclr repo, then the root of | ||
| this repo serves to find the diff compiler and `CORE_ROOT` directory. (Note that we have no reasonable | ||
| default for determining what the baseline toolset or repo is. This is specified with the `--base_root` argument.) |
There was a problem hiding this comment.
This is specified with the
--base_rootargument
or by providing a full path to the --base argument.
| syntax.DefineOption("c|corelib", ref _corelib, "Diff System.Private.CoreLib.dll."); | ||
| syntax.DefineOption("f|frameworks", ref _frameworks, "Diff frameworks."); | ||
| syntax.DefineOption("benchmarks", ref _benchmarks, "Diff core benchmarks. Must pass --test_root."); | ||
| syntax.DefineOption("tests", ref _tests, "Diff all tests. Must pass --test_root."); |
There was a problem hiding this comment.
Don't need to pass --test_root for these if it can be defaulted.
| // using git. | ||
| // | ||
| // NOTE: we shouldn't do this unless it will be used, that is, if there are some | ||
| // arguments that are currently unspecified and need this to compute their default. |
There was a problem hiding this comment.
Can you get rid of this NOTE comment now that you're computing needDiffRoot?
|
|
||
| if (_build == null) | ||
| { | ||
| buildList = new List<string> { "release", "checked", "debug" }; |
| break; | ||
| } | ||
|
|
||
| if (!needCoreRoot && !needCrossgen && !needBasePath && !needDiffPath && !needTestTree) |
There was a problem hiding this comment.
If you can find an appropriate basePath and diffPath on x64 but can't find one of coreRoot/crossgen/testTree on x64, or similarly if you can find coreRoot and crossgen and testTree on x64 but can't find one of basePath/diffPath, and you can find all 5 on x86, it looks like this logic would lock in the set it finds on x64 and then just find the others on x86 and then try to run using defaults with mismatched architectures.
|
|
||
| if (_benchmarks && (_testPath == null)) | ||
| { | ||
| DisplayErrorMessage("--benchmarks requires specifying --test_root as well"); |
There was a problem hiding this comment.
--test_root or --diff_root or running in the coreclr tree
| if (_tests && (_testPath == null)) | ||
| { | ||
| _syntaxResult.ReportError("Specify --output <path>"); | ||
| DisplayErrorMessage("--tests requires specifying --test_root as well"); |
There was a problem hiding this comment.
Ditto re: default test_root
| if (!_corelib && !_frameworks && !_benchmarks && !_tests) | ||
| { | ||
| _syntaxResult.ReportError("Can't find --output path."); | ||
| // Setting --corelib as the default |
There was a problem hiding this comment.
Maybe move this to SetDefaults()?
|
Forgot to mention: I did pull down and try out the latest changes, and yes they do work fine in my typical workflow. |
Short summary:
1. Improved usage model for jit-diff, especially, add support for much simpler
command lines using better defaults. Read the rewritten diffs.md
for details.
2. Improved jit-diff parallelism when diffing the test tree. (Previously,
dasm generation within a recursive directory walk was not parallel.)
3. Changed jit-diff argument parsing to output the usage message on (most)
errors (namely, the errors we validate, not the errors the argument
library validates. It would be nice to do both.).
4. Fixed many crashing bugs
Details:
Using jit-diff is cumbersome due to the need to specify so many
long paths. These can be specified in the config.json file in
the directory pointed to by the `JIT_UTILS_ROOT` environment
variable, but that is inflexible.
This change introduces an alternate way to specify all the required
data for jit-diff, by detecting or specifying the dotnet/coreclr
repo root, and automatically finding all the paths that are required.
The defaults can be altered by using the new `--base_root`, `--diff_root`,
`--arch`, and `--build` arguments, or their respective config.json settings.
See the rewritten diffs.md document for much more detail and various
examples of using this.
Also:
1. To generate asm diffs for the test tree, specify the new "--tests"
argument, as well as the "--test_root" argument (if "--test_root" can't
be determined using the defaults).
2. jit-diff now automatically runs jit-analyze. It now has a "--noanalyze"
option to prevent this.
3. jit-diff now takes an optional "--gcinfo" argument (which it passes
through to jit-dasm) to specify emitting GC info into the generated dasm
files.
4. jit-format automatically detects the repo root, if run with the
current directory within the dotnet/coreclr repo. So, the "--core_root"
argument is no longer required, if the repo root can be found.
5. Rewrote "getting started" document to account for new defaults,
and other changes.
6. Move all cijobs documentation to cijobs.md.
7. Remove `--tag` option from `jit-dasm`: simply pass the `--output` path you desire.
8. Support diff'ing System.Private.CoreLib.dll or the frameworks assemblies, in addition to
the benchmarks or the full test tree. I regularized this, and added a lot of missing
argument checking. I also renamed the arguments since "only" is incorrect. So, now
there is `--corelib`, `--frameworks`, `--tests`, and `--benchmarks`.
9. Removed `jit-diff install --last_successful` option because it didn't work.
10. Removed the two old sample json files (that didn't work), and replace them with
a sample config.json file that does.
You now must specify `--base` to generate baselines, and `--diff` to generate diffs. If you specify these without also specifying a path, defaults for these arguments are found.
If there were no prior installed tools we would run into a null exception. Add code for the case where the install is the first one.
Previously, the `--output` parameter was used as the actual directory where the data would be placed. Now, a subdirectory with pattern `<job name>-<build number>` is created within the output directory. Thus, `--output` is now a "base" directory for cijobs copy output.
Also: 1. Add some useful warning messages to `jit-diff list`. 2. Fix `jit-diff install --last_successful`
Created a new `src/util` directory to put code common to all tools. Created a util.cs there with a "Utility" class. Moved several functions there that were already copied across various tools. In jit-diff, created new diff.cs, install.cs, and uninstall.cs files to split out the code specific to those commands into their own files.
|
I've updated the changes with to reflect code review feedback, as well as:
@russellhadley @JosephTremoulet PTAL |
|
About the only thing I didn't address were Joe's two top-level concerns: (1) worry about errors getting lost in the output spew. I think it would be easy to capture all the error/warning messages and replay them at the end. Future work. (2) worry about the strategy of iterating arch/build to find defaults. |
Aside from that, LGTM, thanks. |
|
I thought about the cijobs output path, but hoped the change wouldn't cause problems. Of course, I was wrong :-) I actually thought it might have been a bug, since the "tag" (final directory name component) was already being constructed, but never used. I'll probably need to add I can make the cijobs copy existing output file check a warning, no problem. When I had that happen, cijobs crashed; I think in the unzip phase. Maybe I can look more carefully at what caused the crash. |
This is used by "jit-diff install" to allow cijobs to create an appropriately named output directory based on job name and build number.
1. Stop finding a default for crossgen. There already is a reasonable default being computed. 2. Fix a File/Directory not found confusion bug. 3. Require --base for generating baselines, and --diff for generating diffs, even if there is a "base" and/or "diff" specified in the config.json file.
|
@dotnet/jit-contrib @dotnet/arm64-contrib @dotnet/arm32-contrib I am planning to merge this change soon. Note that the command-line for jit-diff changes somewhat drastically with this change (although mostly in a backwards-compatible way). If you have any questions, let me know. |
Short summary:
command lines using better defaults. Read the rewritten diffs.md
for details.
dasm generation within a recursive directory walk was not parallel.)
errors (namely, the errors we validate, not the errors the argument
library validates. It would be nice to do both.).
Details:
Using jit-diff is cumbersome due to the need to specify so many
long paths. These can be specified in the config.json file in
the directory pointed to by the
JIT_UTILS_ROOTenvironmentvariable, but that is inflexible.
This change introduces an alternate way to specify all the required
data for jit-diff, by detecting or specifying the dotnet/coreclr
repo root, and automatically finding all the paths that are required.
The defaults can be altered by using the new
--base_root,--diff_root,--arch, and--buildarguments, or their respective config.json settings.See the rewritten diffs.md document for much more detail and various
examples of using this.
Also:
argument, as well as the "--test_root" argument (if "--test_root" can't
be determined using the defaults).
option to prevent this.
through to jit-dasm) to specify emitting GC info into the generated dasm
files.
current directory within the dotnet/coreclr repo. So, the "--core_root"
argument is no longer required, if the repo root can be found.
and other changes.
--tagoption fromjit-dasm: simply pass the--outputpath you desire.the benchmarks or the full test tree. I regularized this, and added a lot of missing
argument checking. I also renamed the arguments since "only" is incorrect. So, now
there is
--corelib,--frameworks,--tests, and--benchmarks.jit-diff install --last_successfuloption because it didn't work.a sample config.json file that does.