From patchwork Tue Mar 6 12:43:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 10261577 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3CDBB602C8 for ; Tue, 6 Mar 2018 12:43:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2D88628A57 for ; Tue, 6 Mar 2018 12:43:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2208E28E43; Tue, 6 Mar 2018 12:43:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C187A28AF4 for ; Tue, 6 Mar 2018 12:43:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E13006E6B1; Tue, 6 Mar 2018 12:43:30 +0000 (UTC) X-Original-To: Intel-gfx@lists.freedesktop.org Delivered-To: Intel-gfx@lists.freedesktop.org Received: from mail-wr0-x243.google.com (mail-wr0-x243.google.com [IPv6:2a00:1450:400c:c0c::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5BF3D6E6A4 for ; Tue, 6 Mar 2018 12:43:29 +0000 (UTC) Received: by mail-wr0-x243.google.com with SMTP id k9so20758688wre.9 for ; Tue, 06 Mar 2018 04:43:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ursulin-net.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zM/JU5sJXLUE4raeifMHUQXtQ408E2e4ZLw0KH94y08=; b=RHVevFwZ1BQg/XvND+FFwe3mz+ywUZ4oE7fYb1nZOoinC18XJ60rFKV/+oQTjJZFC3 2V1V40PSmtZqQG9TJIqZsbfb1Xtwmgb/CBMp8/6EK/bjUF3IyyLxkDcrThIBtK6iPFjM Xo+zWw9tpWrIuTYMpwRLapc2jUKtXXowkFob7XfR0CkbOsn1GBRBPwX8neHkxHRtVGgH SRz7vuUfK+kj3TtZ7nrCZhGQL4xs5UiAudZ4z0gAMgd37HTukLfC1kNMld53EuGVUxOb wD8itR1DlbRnokHfy8ijexoxG0Uq3XHDtXq2z6txhCaoZu9/TeIvq3zTYoSJBI1rA+4e CyVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zM/JU5sJXLUE4raeifMHUQXtQ408E2e4ZLw0KH94y08=; b=B4l0m9IgPnmKXN08JZImPTta7OcvFkYsJKu2LgOpY1QVcRg5LJE+wh6zQYwNON3fZm 4zoDl6cch7Yxo2fxknDAzqK0nyd7++8MdY1xCUyVx4DYQdYoqMNs9oiLF3bPH7kxrU8Z YwuKizVso4jYCOaJh/BjWEXqzWlBMXyxQvLTbDM/bbppR71T4JNuYGCHpVV86/tXiBJ6 Ve+BUrcH4Sn9lUgg8ZV5klUrdTdIFQKyKfn2VfY3UWjkkHD1j3gO0e4s1wMnYnS4Dc6b 8f2TUU69vH7M/3UHA+QcaKOgjYUhxu5EZC5tHCl2JKVdQBAEIUKYBLtemZjX1B5iacAj /iNw== X-Gm-Message-State: APf1xPAYQLmDxBsJv3IqPBhpw/s7zol7C+YPgRe6ptfxZaAEpibV+Xjw ihOrRAEDLjYfByio8LWaLvFLj0KJ X-Google-Smtp-Source: AG47ELs19cTmfN02f7kIPPy4JSocC580W2EaGtp7qcbqQ6JxvyiSygLWAVGz9Lme/dxcFlnRG5ByGA== X-Received: by 10.223.199.71 with SMTP id b7mr16532616wrh.228.1520340208028; Tue, 06 Mar 2018 04:43:28 -0800 (PST) Received: from localhost.localdomain ([95.146.144.186]) by smtp.gmail.com with ESMTPSA id v8sm3646560wmh.25.2018.03.06.04.43.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Mar 2018 04:43:27 -0800 (PST) From: Tvrtko Ursulin X-Google-Original-From: Tvrtko Ursulin To: igt-dev@lists.freedesktop.org Date: Tue, 6 Mar 2018 12:43:07 +0000 Message-Id: <20180306124315.30208-4-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180306124315.30208-1-tvrtko.ursulin@linux.intel.com> References: <20180306124315.30208-1-tvrtko.ursulin@linux.intel.com> Subject: [Intel-gfx] [PATCH i-g-t 03/11] scripts/trace.pl: Sort order X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Intel-gfx@lists.freedesktop.org MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP From: John Harrison Add an extra level to the databse key sort so that the ordering is deterministic. If the time stamp matches, it now compares the key itself as well (context/seqno). This makes it much easier to determine if a change has actually broken anything. Previously back to back runs with no changes could still produce different output, especially when adding extra debug output during the calculations. As the comparison test is now more than a single equation, moved it out into a separate sort function. v2: Re-work sort func for readability/performance [Tvrtko] Signed-off-by: John Harrison Cc: Tvrtko Ursulin Reviewed-by: Tvrtko Ursulin --- scripts/trace.pl | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/scripts/trace.pl b/scripts/trace.pl index 6b784ac6ab1f..d571a870fca2 100755 --- a/scripts/trace.pl +++ b/scripts/trace.pl @@ -539,7 +539,29 @@ my (%submit_avg, %execute_avg, %ctxsave_avg); my $last_ts = 0; my $first_ts; -my @sorted_keys = sort {$db{$a}->{'start'} <=> $db{$b}->{'start'}} keys %db; +sub sortStart { + my $as = $db{$a}->{'start'}; + my $bs = $db{$b}->{'start'}; + my $val; + + $val = $as <=> $bs; + $val = $a cmp $b if $val == 0; + + return $val; +} + +sub sortQueue { + my $as = $db{$a}->{'queue'}; + my $bs = $db{$b}->{'queue'}; + my $val; + + $val = $as <=> $bs; + $val = $a cmp $b if $val == 0; + + return $val; +} + +my @sorted_keys = sort sortStart keys %db; my $re_sort = 0; die "Database changed size?!" unless scalar(@sorted_keys) == $key_count; @@ -589,9 +611,9 @@ foreach my $key (@sorted_keys) { $ctxsave_avg{$ring} += $db{$key}->{'end'} - $db{$key}->{'notify'}; } -@sorted_keys = sort {$db{$a}->{'start'} <=> $db{$b}->{'start'}} keys %db if $re_sort; +@sorted_keys = sort sortStart keys %db if $re_sort; -foreach my $ring (keys %batch_avg) { +foreach my $ring (sort keys %batch_avg) { $batch_avg{$ring} /= $batch_count{$ring}; $batch_total_avg{$ring} /= $batch_count{$ring}; $submit_avg{$ring} /= $batch_count{$ring}; @@ -831,7 +853,7 @@ print <{'queue'} <=> $db{$b}->{'queue'}} keys %db) { +foreach my $key (sort sortQueue keys %db) { my ($name, $ctx, $seqno) = ($db{$key}->{'name'}, $db{$key}->{'ctx'}, $db{$key}->{'seqno'}); my ($queue, $start, $notify, $end) = ($db{$key}->{'queue'}, $db{$key}->{'start'}, $db{$key}->{'notify'}, $db{$key}->{'end'}); my $submit = $queue + $db{$key}->{'submit-delay'};