Skip to content

Commit c48c6ca

Browse files
authored
Switch to Word2Vec fork (dotnet#17945)
* update git repo url, remove the patch file (not needed anymore) * refactoring: there is no need to have an abstract class if only 1 class derives from it * use CurrentCulture.NumberFormat.NumberDecimalSeparator instead of hardcoded dot (it's , for polish UI and it fails for me) * use .NET Standard way of accessing CurrentCulture to fix the build * updated repor url to our fork + removed dead code
1 parent 958b4e7 commit c48c6ca

File tree

4 files changed

+18
-647
lines changed

4 files changed

+18
-647
lines changed

tests/src/performance/Scenario/JitBench/Benchmarks/MLBenchmark.cs renamed to tests/src/performance/Scenario/JitBench/Benchmarks/Word2VecBenchmark.cs

Lines changed: 17 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,20 @@
33
using System.IO;
44
using System.Text.RegularExpressions;
55
using System.Threading.Tasks;
6-
using System.Reflection;
76
using Microsoft.Xunit.Performance.Api;
87
using System.Runtime.InteropServices;
8+
using System.Globalization;
99

1010
namespace JitBench
1111
{
12-
class Word2VecBenchmark : MLBenchmark
12+
class Word2VecBenchmark : Benchmark
1313
{
14-
public Word2VecBenchmark() : base("Word2Vec") { }
14+
private static readonly HashSet<int> DefaultExitCodes = new HashSet<int>(new[] { 0 });
15+
16+
public Word2VecBenchmark() : base("Word2Vec")
17+
{
18+
ExePath = "Word2VecScenario.dll";
19+
}
1520

1621
public override bool IsArchitectureSupported(Architecture arch)
1722
{
@@ -24,28 +29,10 @@ public override bool IsArchitectureSupported(Architecture arch)
2429
//unless customers tell us its a problem'. I'm OK telling people not to use tiered jitting
2530
//if their app already uses most of the address space on x86, and having an intermitently
2631
//failing test in a perf suite won't give us useful info hence x64 only for this one.
27-
return arch == Architecture.X64;
28-
}
29-
30-
protected override string ExecutableName => "Word2VecScenario.dll";
31-
32-
protected override string GetWord2VecNetSrcDirectory(string outputDir)
33-
{
34-
return Path.Combine(GetWord2VecNetRepoRootDir(outputDir), "Word2VecScenario");
35-
}
36-
}
37-
38-
abstract class MLBenchmark : Benchmark
39-
{
40-
private static readonly HashSet<int> DefaultExitCodes = new HashSet<int>(new[] { 0 });
4132

42-
public MLBenchmark(string name) : base(name)
43-
{
44-
ExePath = ExecutableName;
33+
return arch == Architecture.X64;
4534
}
4635

47-
protected abstract string ExecutableName { get; }
48-
4936
public override async Task Setup(DotNetInstallation dotNetInstall, string outputDir, bool useExistingSetup, ITestOutputHelper output)
5037
{
5138
if(!useExistingSetup)
@@ -67,11 +54,8 @@ async Task CloneWord2VecNetRepo(string outputDir, ITestOutputHelper output)
6754
string word2VecNetRepoRootDir = GetWord2VecNetRepoRootDir(outputDir);
6855
FileTasks.DeleteDirectory(word2VecNetRepoRootDir, output);
6956

70-
string word2VecPatchFullPath = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), Word2VecNetPatch);
71-
7257
await ExecuteGitCommand($"clone {Word2VecNetRepoUrl} {word2VecNetRepoRootDir}", output);
7358
await ExecuteGitCommand($"checkout {Word2VecNetCommitSha1Id}", output, workingDirectory: word2VecNetRepoRootDir);
74-
await ExecuteGitCommand($"apply {word2VecPatchFullPath}", output, workingDirectory: word2VecNetRepoRootDir);
7559
}
7660

7761
async Task ExecuteGitCommand(string arguments, ITestOutputHelper output, string workingDirectory = null)
@@ -146,6 +130,7 @@ void AddConsoleMetrics(IterationResult result, string stdout, ITestOutputHelper
146130
double? trainingTime = null;
147131
double? firstSearchTime = null;
148132
double? steadyStateMedianTime = null;
133+
var currentDecimalSeparator = CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator;
149134

150135
using (var reader = new StringReader(stdout))
151136
{
@@ -166,7 +151,7 @@ void AddConsoleMetrics(IterationResult result, string stdout, ITestOutputHelper
166151
continue;
167152
}
168153

169-
match = Regex.Match(line, @"^Steadystate median search time: \s*(\d+\.\d+)ms$");
154+
match = Regex.Match(line, $@"^Steadystate median search time: \s*(\d+\{currentDecimalSeparator}\d+)ms$");
170155
if (match.Success && match.Groups.Count == 2)
171156
{
172157
//many lines will match, but the final values of these variables will be from the last batch which is presumably the
@@ -226,7 +211,10 @@ protected static string GetWord2VecNetRepoRootDir(string outputDir)
226211
return Path.Combine(outputDir, "W");
227212
}
228213

229-
protected abstract string GetWord2VecNetSrcDirectory(string outputDir);
214+
protected string GetWord2VecNetSrcDirectory(string outputDir)
215+
{
216+
return Path.Combine(GetWord2VecNetRepoRootDir(outputDir), "Word2VecScenario");
217+
}
230218

231219
string GetWord2VecNetPublishDirectory(DotNetInstallation dotNetInstall, string outputDir, string tfm)
232220
{
@@ -257,15 +245,11 @@ string GetCoreClrRoot()
257245
return workspace;
258246
}
259247

260-
private const string Word2VecNetRepoUrl = "https://github.com/eabdullin/Word2Vec.Net";
261-
private const string Word2VecNetCommitSha1Id = "6012a2b5b886926918d51b1b56387d785115f448";
262-
private const string Word2VecNetPatch = "word2vecnet.patch";
263-
private const string EnvironmentFileName = "Word2VecNetEnvironment.txt";
264-
private const string StoreDirName = ".store";
248+
private const string Word2VecNetRepoUrl = "https://github.com/dotnet-perf-bot/Word2Vec.Net.git";
249+
private const string Word2VecNetCommitSha1Id = "bbf60216bd735ba2ccc3a54570ce735789968f2d";
265250
private readonly Metric TrainingMetric = new Metric("Training", "ms");
266251
private readonly Metric FirstSearchMetric = new Metric("First Search", "ms");
267252
private readonly Metric MedianSearchMetric = new Metric("Median Search", "ms");
268-
private readonly Metric MeanSearchMetric = new Metric("Mean Search", "ms");
269253
}
270254
}
271255

tests/src/performance/Scenario/JitBench/JitBench.csproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,5 @@
5454
Overwrite="true"
5555
Encoding="Unicode"/>
5656
</Target>
57-
<Target Name="AfterBuild">
58-
<Copy SourceFiles="Resources\word2vecnet.patch" DestinationFolder="$(OutDir)" />
59-
</Target>
6057

6158
</Project>

0 commit comments

Comments
 (0)