Skip to content

Commit

Permalink
revert parallelizm of similarity calculation loop
Browse files Browse the repository at this point in the history
  • Loading branch information
discostu105 committed Feb 22, 2019
1 parent e928a7c commit 8dab978
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/SuperDumpService/Services/SimilarityService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,20 +138,20 @@ public async Task CalculateSimilarityAsync(DumpMetainfo dumpA, bool force, DateT
var allDumps = dumpRepo.GetAll().Where(x => x.Created >= timeFrom).OrderBy(x => x.Created);
Console.WriteLine($"starting CalculateSimilarity for {allDumps.Count()} dumps; {dumpA} (TID:{Thread.CurrentThread.ManagedThreadId})");

var tasks = allDumps.Select(dumpB => Task.Run(async () => {
foreach(var dumpB in allDumps) {
if (!force) {
var existingSimilarity = await relationShipRepo.GetRelationShip(dumpA.Id, dumpB.Id);
if (existingSimilarity != 0) {
// relationship already exists. skip!
// but make sure the relationship is stored bi-directional
await relationShipRepo.UpdateSimilarity(dumpA.Id, dumpB.Id, existingSimilarity);
return;
continue;
}
}

if (!PreSelectOnMetadata(dumpA, dumpB)) return;
if (!PreSelectOnMetadata(dumpA, dumpB)) continue;
var resultB = await GetOrCreateMiniInfo(dumpB.Id);
if (!PreSelectOnResults(resultA, resultB)) return;
if (!PreSelectOnResults(resultA, resultB)) continue;

CrashSimilarity crashSimilarity = CrashSimilarity.Calculate(resultA, resultB);

Expand All @@ -160,8 +160,7 @@ public async Task CalculateSimilarityAsync(DumpMetainfo dumpA, bool force, DateT
await relationShipRepo.UpdateSimilarity(dumpA.Id, dumpB.Id, crashSimilarity.OverallSimilarity);
}
//Console.WriteLine($"CalculateSimilarity.Finished for {dumpA}/{dumpB} ({i} to go...); (elapsed: {sw.Elapsed}) (TID:{Thread.CurrentThread.ManagedThreadId})");
}));
await Task.WhenAll(tasks);
}

await relationShipRepo.FlushDirtyRelationships();
swTotal.Stop();
Expand Down

0 comments on commit 8dab978

Please sign in to comment.