Skip to content

Fix the benchmarks #1001

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Sep 28, 2018
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions nuget.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<!--To inherit the global NuGet package sources remove the <clear/> line below -->
<clear />
Copy link
Member

Choose a reason for hiding this comment

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

@eerhardt will this affect anything else, or will they all keep using the MSBuild source?

Copy link
Member

Choose a reason for hiding this comment

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

I'd like to not have this list duplicated. NuGet.configs are not great because they cannot be modified (either adding new sources or removing sources, or changing locations) without actually modifying the file.

Instead, would it be possible to:

  1. pull the RestoreSources property out of Directory.Build.props and put it in a separate file, say build\NuGetSources.props. Directory.Build.props imports that file.
  2. Change the Benchmark toolchain to import the build\NuGetSources.props file.

That way we don't need to duplicate this list.


In reply to: 220023911 [](ancestors = 220023911)

Copy link
Member Author

Choose a reason for hiding this comment

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

@eerhardt I have changed the way it works: now our project generator generates a simple .csproj file which includes the native dependencies and does not ignore Directory.Build.props file so BDN is using the nuget feeds defined in Directory.Build.props

<add key="nuget" value="https://api.nuget.org/v3/index.json" />
<add key="net core" value=" https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" />
</packageSources>
</configuration>
50 changes: 50 additions & 0 deletions test/Microsoft.ML.Benchmarks/Harness/Configs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Diagnosers;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Toolchains;
using BenchmarkDotNet.Toolchains.CsProj;
using BenchmarkDotNet.Toolchains.DotNetCli;
using Microsoft.ML.Benchmarks.Harness;

namespace Microsoft.ML.Benchmarks
{
public class RecommendedConfig : ManualConfig
{
public RecommendedConfig()
{
Add(DefaultConfig.Instance
.With(GetJobDefinition().With(CreateToolchain()))
.With(new ExtraMetricColumn())
.With(MemoryDiagnoser.Default));

UnionRule = ConfigUnionRule.AlwaysUseLocal;
}

protected virtual Job GetJobDefinition()
=> Job.Default
.WithWarmupCount(1) // ML.NET benchmarks are typically CPU-heavy benchmarks, 1 warmup is usually enough
.WithMaxIterationCount(20);
Copy link
Contributor

Choose a reason for hiding this comment

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

@adamsitnik I think we should make the default configuration as the train config as most of the tests are running in the train configuration ?

Copy link
Member Author

Choose a reason for hiding this comment

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

@Anipik thank you for the suggestion! The TrainConfig is a very specific config, I would prefer to not make it a default one


/// <summary>
/// we need our own toolchain because MSBuild by default does not copy recursive native dependencies to the output
/// </summary>
private IToolchain CreateToolchain()
{
var csProj = CsProjCoreToolchain.Current.Value;
var tfm = NetCoreAppSettings.Current.Value.TargetFrameworkMoniker;

return new Toolchain(
tfm,
new ProjectGenerator(tfm),
csProj.Builder,
csProj.Executor);
}
}

public class TrainConfig : RecommendedConfig
{
protected override Job GetJobDefinition()
=> Job.Dry // the "Dry" job runs the benchmark exactly once, without any warmup to mimic real-world scenario
.WithLaunchCount(3); // BDN will run 3 dedicated processes, sequentially
}
}
1 change: 0 additions & 1 deletion test/Microsoft.ML.Benchmarks/Numeric/Ranking.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ public void TrainTest_Ranking_MSLRWeb10K_RawNumericFeatures_LightGBMRanking()
}
}

[Config(typeof(PredictConfig))]
public class RankingTest
{
private string _mslrWeb10k_Validate;
Expand Down
24 changes: 0 additions & 24 deletions test/Microsoft.ML.Benchmarks/PredictConfig.cs

This file was deleted.

21 changes: 1 addition & 20 deletions test/Microsoft.ML.Benchmarks/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
// See the LICENSE file in the project root for more information.

using BenchmarkDotNet.Running;
using BenchmarkDotNet.Toolchains;
using BenchmarkDotNet.Toolchains.CsProj;
using BenchmarkDotNet.Toolchains.DotNetCli;
using Microsoft.ML.Benchmarks.Harness;
using System.Globalization;
using System.IO;
using System.Threading;
Expand All @@ -22,22 +18,7 @@ class Program
static void Main(string[] args)
=> BenchmarkSwitcher
.FromAssembly(typeof(Program).Assembly)
.Run(args);

/// <summary>
/// we need our own toolchain because MSBuild by default does not copy recursive native dependencies to the output
/// </summary>
internal static IToolchain CreateToolchain()
{
var csProj = CsProjCoreToolchain.Current.Value;
var tfm = NetCoreAppSettings.Current.Value.TargetFrameworkMoniker;

return new Toolchain(
tfm,
new ProjectGenerator(tfm),
csProj.Builder,
csProj.Executor);
}
.Run(args, new RecommendedConfig());

internal static string GetInvariantCultureDataPath(string name)
{
Expand Down
4 changes: 4 additions & 0 deletions test/Microsoft.ML.Benchmarks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ This project contains performance benchmarks.
**Pre-requisite:** On a clean repo, `build.cmd` at the root installs the right version of dotnet.exe and builds the solution. You need to build the solution in `Release` with native dependencies.

build.cmd -release -buildNative

Moreover, to run some of the benchmarks you have to download external dependencies.

build.cmd -- /t:DownloadExternalTestFiles /p:IncludeBenchmarkData=true

1. Navigate to the benchmarks directory (machinelearning\test\Microsoft.ML.Benchmarks)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ public void CV_Multiclass_WikiDetox_WordEmbeddings_SDCAMC()
}
}

[Config(typeof(PredictConfig))]
public class MultiClassClassificationTest
{
private string _dataPath_Wiki;
Expand Down
25 changes: 0 additions & 25 deletions test/Microsoft.ML.Benchmarks/TrainConfig.cs

This file was deleted.