From efd2c59675f9b1fdaf6cbf864f7d7e365347f57f Mon Sep 17 00:00:00 2001 From: Jesse Schwartzentruber Date: Tue, 4 Feb 2020 15:24:24 -0500 Subject: [PATCH] [crashmanager] Show all signature matches when trying to bucket a crash. Searching for matching buckets for an unbucketed crash only shows "good" matches, where "good" is fairly arbitrary. Instead show all matches (ordered by quality of the match), and let the user decide. --- server/crashmanager/views.py | 116 +++++++++++++++++------------------ 1 file changed, 57 insertions(+), 59 deletions(-) diff --git a/server/crashmanager/views.py b/server/crashmanager/views.py index ef95a70d3..caf5b1209 100644 --- a/server/crashmanager/views.py +++ b/server/crashmanager/views.py @@ -883,66 +883,64 @@ def findSignatures(request, crashid): matchingBucket = bucket break - # TODO: This could be made configurable through a GET parameter - if distance <= 4: - proposedCrashSignature = signature.fit(entry.crashinfo) - if proposedCrashSignature: - # We now try to determine how this signature will behave in other buckets - # If the signature matches lots of other buckets as well, it is likely too - # broad and we should not consider it (or later rate it worse than others). - matchesInOtherBuckets = 0 - matchesInOtherBucketsLimitExceeded = False - nonMatchesInOtherBuckets = 0 - otherMatchingBucketIds = [] - for otherBucket in buckets: - if otherBucket.pk == bucket.pk: - continue - - if otherBucket.pk not in firstEntryPerBucketCache: - c = CrashEntry.objects.filter(bucket=otherBucket).first() - firstEntryPerBucketCache[otherBucket.pk] = c - if c: - # Omit testcase for performance reasons for now - firstEntryPerBucketCache[otherBucket.pk] = c.getCrashInfo(attachTestcase=False) - - firstEntryCrashInfo = firstEntryPerBucketCache[otherBucket.pk] - if firstEntryCrashInfo: + proposedCrashSignature = signature.fit(entry.crashinfo) + if proposedCrashSignature: + # We now try to determine how this signature will behave in other buckets + # If the signature matches lots of other buckets as well, it is likely too + # broad and we should not consider it (or later rate it worse than others). + matchesInOtherBuckets = 0 + matchesInOtherBucketsLimitExceeded = False + nonMatchesInOtherBuckets = 0 + otherMatchingBucketIds = [] + for otherBucket in buckets: + if otherBucket.pk == bucket.pk: + continue + + if otherBucket.pk not in firstEntryPerBucketCache: + c = CrashEntry.objects.filter(bucket=otherBucket).first() + firstEntryPerBucketCache[otherBucket.pk] = c + if c: # Omit testcase for performance reasons for now - if proposedCrashSignature.matches(firstEntryCrashInfo): - matchesInOtherBuckets += 1 - otherMatchingBucketIds.append(otherBucket.pk) - - # We already match too many foreign buckets. Abort our search here - # to speed up the response time. - if matchesInOtherBuckets > 5: - matchesInOtherBucketsLimitExceeded = True - break - else: - nonMatchesInOtherBuckets += 1 - - bucket.offCount = distance - - if matchesInOtherBuckets + nonMatchesInOtherBuckets > 0: - bucket.foreignMatchPercentage = round((float(matchesInOtherBuckets) / ( - matchesInOtherBuckets + nonMatchesInOtherBuckets)) * 100, 2) - else: - bucket.foreignMatchPercentage = 0 - - bucket.foreignMatchCount = matchesInOtherBuckets - bucket.foreignMatchLimitExceeded = matchesInOtherBucketsLimitExceeded - - if matchesInOtherBuckets == 0: - bucket.foreignColor = "green" - elif matchesInOtherBuckets < 3: - bucket.foreignColor = "yellow" - else: - bucket.foreignColor = "red" - - # Only include the bucket in our results if the number of matches in other buckets is below - # out limit. Otherwise, it will just distract the user. - if matchesInOtherBuckets <= 5: - bucket.linkToOthers = ",".join([str(x) for x in otherMatchingBucketIds]) - similarBuckets.append(bucket) + firstEntryPerBucketCache[otherBucket.pk] = c.getCrashInfo(attachTestcase=False) + + firstEntryCrashInfo = firstEntryPerBucketCache[otherBucket.pk] + if firstEntryCrashInfo: + # Omit testcase for performance reasons for now + if proposedCrashSignature.matches(firstEntryCrashInfo): + matchesInOtherBuckets += 1 + otherMatchingBucketIds.append(otherBucket.pk) + + # We already match too many foreign buckets. Abort our search here + # to speed up the response time. + if matchesInOtherBuckets > 5: + matchesInOtherBucketsLimitExceeded = True + break + else: + nonMatchesInOtherBuckets += 1 + + bucket.offCount = distance + + if matchesInOtherBuckets + nonMatchesInOtherBuckets > 0: + bucket.foreignMatchPercentage = round((float(matchesInOtherBuckets) / ( + matchesInOtherBuckets + nonMatchesInOtherBuckets)) * 100, 2) + else: + bucket.foreignMatchPercentage = 0 + + bucket.foreignMatchCount = matchesInOtherBuckets + bucket.foreignMatchLimitExceeded = matchesInOtherBucketsLimitExceeded + + if matchesInOtherBuckets == 0: + bucket.foreignColor = "green" + elif matchesInOtherBuckets < 3: + bucket.foreignColor = "yellow" + else: + bucket.foreignColor = "red" + + # Only include the bucket in our results if the number of matches in other buckets is below + # out limit. Otherwise, it will just distract the user. + if matchesInOtherBuckets <= 5: + bucket.linkToOthers = ",".join([str(x) for x in otherMatchingBucketIds]) + similarBuckets.append(bucket) if matchingBucket: entry.bucket = matchingBucket