From patchwork Tue Mar 6 12:43:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 10261575 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 A6784602C8 for ; Tue, 6 Mar 2018 12:43:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 96C3B28A57 for ; Tue, 6 Mar 2018 12:43:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8B2EE28E43; Tue, 6 Mar 2018 12:43:32 +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 3F1B728A57 for ; Tue, 6 Mar 2018 12:43:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A6C3C6E6B6; 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-x242.google.com (mail-wr0-x242.google.com [IPv6:2a00:1450:400c:c0c::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7D7E96E6A4 for ; Tue, 6 Mar 2018 12:43:28 +0000 (UTC) Received: by mail-wr0-x242.google.com with SMTP id u49so20769009wrc.10 for ; Tue, 06 Mar 2018 04:43:28 -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=Z4mI/dJA40bK2MPPXUGMFgrZYaYyhFLJxdMVP0G98Hs=; b=iGt2W7SKkP4qeTQWIrFK9H+jaq0BPFReZDeTJ1Es92GFzpl/9q7chJi+gbgSb/9Fy7 C9DV7af+zkG+4447t76/qxN3FNaOcM8LgKhD7iCQ8q4cudnJ14lgw9xYREyUs9xX0zdc eTkTSeBsP7uLUSHU+iI7kHY4LtT47eb5k7Oo3JahJTKzA6VXzx4G1OIrs+VYVxcmeXYw ULwaze3p0ssQbQrw/wwllEFGryVIiuMZiFiiesEPwxoZNaZFhO61fwaSlKU/D2m5BQ+A 3ShxoGciWoiG9Rx8BbVSNzN57sz2z4GAdMQHmM2bpOFYU5nNMKreTTZhKIIOcWahU0aw zXoA== 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=Z4mI/dJA40bK2MPPXUGMFgrZYaYyhFLJxdMVP0G98Hs=; b=BzZXJk5/nvb/59U1vJvQY1uTYq97Mbxa3I8O4USRO5lcU4Be1auA8dd8uT5fbTZiqL a3WtbAYTEMSfM32/LB18N7fBlhNGXGUABo9MxChciSU5cT+vwPHkbrZT8sCqUYNLN1DU W7dkL9/3KvAoi/S+lBzdUYVM7it9Bd6Ppjsm9nnm4uep9kBmQlWle7t2860IKcbqWZyn gK/OQoKtaWkdvs7tPLnIUhMca1Mf4sLaBQgNp+WFnl/oY4EhwvVFaK2cMuZrc7L2gR0h MXAL4TzTHtAd/W+GES6b7ZHBPmrJL6Q0ZYrcLa9zU6DIkTO5W10FFndceXQfxRll0rK2 aHdw== X-Gm-Message-State: APf1xPCHPIzdL8IASztFjeWZqzmb+Yq1W5WehuViH9YR4qm7MYItrd0W 3YIAChM0celiO9npliiVjPFljw== X-Google-Smtp-Source: AG47ELvnIabI+FiKAaFDEJWktOXmpRC5ualLj7/OsBwSHeMJMsKwhH3xWwgJ8Kknr64F1uoUB8wPKA== X-Received: by 10.223.183.39 with SMTP id l39mr16943261wre.214.1520340207090; Tue, 06 Mar 2018 04:43:27 -0800 (PST) Received: from localhost.localdomain ([95.146.144.186]) by smtp.gmail.com with ESMTPSA id v8sm3646560wmh.25.2018.03.06.04.43.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Mar 2018 04:43:26 -0800 (PST) From: Tvrtko Ursulin X-Google-Original-From: Tvrtko Ursulin To: igt-dev@lists.freedesktop.org Date: Tue, 6 Mar 2018 12:43:06 +0000 Message-Id: <20180306124315.30208-3-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 02/11] scripts/trace.pl: More hash key optimisations 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 Cache the key count value rather than querying the hash every time. Also assert that the database does not magically change size after the fixups. v2: Rename variable according to style guide [Tvrtko] v3: Reverted accidental style change and added a blank line. [Tvrtko] Signed-off-by: John Harrison Cc: Tvrtko Ursulin Reviewed-by: Tvrtko Ursulin --- scripts/trace.pl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/trace.pl b/scripts/trace.pl index d6686833b3e9..6b784ac6ab1f 100755 --- a/scripts/trace.pl +++ b/scripts/trace.pl @@ -508,6 +508,7 @@ foreach my $key (keys %db) { } # Fix up incompletes +my $key_count = scalar(keys %db); foreach my $key (keys %db) { next unless exists $db{$key}->{'incomplete'}; @@ -522,7 +523,7 @@ foreach my $key (keys %db) { $next_key = db_key($ring, $ctx, $seqno + $i); $i++; } until ((exists $db{$next_key} and not exists $db{$next_key}->{'incomplete'}) - or $i > scalar(keys(%db))); # ugly stop hack + or $i > $key_count); # ugly stop hack if (exists $db{$next_key}) { $db{$key}->{'notify'} = $db{$next_key}->{'end'}; @@ -541,6 +542,8 @@ my $first_ts; my @sorted_keys = sort {$db{$a}->{'start'} <=> $db{$b}->{'start'}} keys %db; my $re_sort = 0; +die "Database changed size?!" unless scalar(@sorted_keys) == $key_count; + foreach my $key (@sorted_keys) { my $ring = $db{$key}->{'ring'}; my $end = $db{$key}->{'end'}; @@ -565,7 +568,7 @@ foreach my $key (@sorted_keys) { do { $next_key = db_key($ring, $ctx, $seqno + $i); $i++; - } until (exists $db{$next_key} or $i > scalar(keys(%db))); # ugly stop hack + } until (exists $db{$next_key} or $i > $key_count); # ugly stop hack # 20us tolerance if (exists $db{$next_key} and $db{$next_key}->{'start'} < $start + 20) {