From patchwork Sat May 14 03:34:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emilio Cota X-Patchwork-Id: 9094591 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 3ED61BF29F for ; Sat, 14 May 2016 03:41:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 77B2F201EC for ; Sat, 14 May 2016 03:41:26 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A89C12017E for ; Sat, 14 May 2016 03:41:25 +0000 (UTC) Received: from localhost ([::1]:36586 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b1QSC-0006Pj-RR for patchwork-qemu-devel@patchwork.kernel.org; Fri, 13 May 2016 23:41:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46968) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b1QMA-00038B-NF for qemu-devel@nongnu.org; Fri, 13 May 2016 23:35:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b1QM4-0005N0-Hq for qemu-devel@nongnu.org; Fri, 13 May 2016 23:35:09 -0400 Received: from out5-smtp.messagingengine.com ([66.111.4.29]:43816) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b1QM2-0005JU-6c for qemu-devel@nongnu.org; Fri, 13 May 2016 23:35:04 -0400 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id DDE7A20A0E for ; Fri, 13 May 2016 23:34:43 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute2.internal (MEProxy); Fri, 13 May 2016 23:34:43 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=braap.org; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=jzb+9WtN356n+ndAUHf++aUboXY=; b=G12w7R mLDss47eWEs2rWJLzmuemcccNjRoYJbygNWW6KfZJYd7ENnSAHB70gK4FaNpl138 8QoZD4ZhUTfZT3NlG0T72+r4OT192ZivtBXvgyGgW2XF06uqQwvIfDmIrI5iYZfG rJxUHA8vJ6EDa2NdgPKj3EHrnFZmY9xWYm90I= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=jzb+9WtN356n+nd AUHf++aUboXY=; b=CcqmnNGlyXVllsgfW19o5qxyvttv9u77Pp9Egmdc1nrpOEe Mu3cWWprQvGHuDvKJHENa/ZslG6KDH2vG7pp4rgfCt/TiVlKOtnR9OyppW8MF/99 AGNFp8UaUm1XBxPgLelL+T1ZVz0WlzPMJbYB3YZzAD5oAHjPh7aCCaGbNzAU= X-Sasl-enc: egdv4k7WyTE8+Bgqw5IUktEX/qQ2r9yDVjMHdo5ZOqM0 1463196883 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 8AF196800EA; Fri, 13 May 2016 23:34:43 -0400 (EDT) From: "Emilio G. Cota" To: QEMU Developers , MTTCG Devel Date: Fri, 13 May 2016 23:34:33 -0400 Message-Id: <1463196873-17737-19-git-send-email-cota@braap.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1463196873-17737-1-git-send-email-cota@braap.org> References: <1463196873-17737-1-git-send-email-cota@braap.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.111.4.29 Subject: [Qemu-devel] [PATCH v5 18/18] translate-all: add tb hash bucket info to 'info jit' dump X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Sergey Fedorov , Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Peter Crosthwaite Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Examples: - Good hashing, i.e. tb_hash_func5(phys_pc, pc, flags): TB count 715135/2684354 [...] TB hash buckets 388775/524288 (74.15% head buckets used) TB hash occupancy 33.04% avg chain occ. Histogram: [0,10)%|? ? ?????|[90,100]% TB hash avg chain 1.017 buckets. Histogram: 1|???|3 - Not-so-good hashing, i.e. tb_hash_func5(phys_pc, pc, 0): TB count 712636/2684354 [...] TB hash buckets 344924/524288 (65.79% head buckets used) TB hash occupancy 31.64% avg chain occ. Histogram: [0,10)%|? ? ?????|[90,100]% TB hash avg chain 1.047 buckets. Histogram: 1|????|4 - Bad hashing, i.e. tb_hash_func5(phys_pc, 0, 0): TB count 702818/2684354 [...] TB hash buckets 112741/524288 (21.50% head buckets used) TB hash occupancy 10.15% avg chain occ. Histogram: [0,10)%|? ? ?????|[90,100]% TB hash avg chain 2.107 buckets. Histogram: [1.0,10.2)|??????????|[83.8,93.0] - Good hashing, but no auto-resize: TB count 715634/2684354 TB hash buckets 8192/8192 (100.00% head buckets used) TB hash occupancy 98.30% avg chain occ. Histogram: [95.3,95.8)%|??????????|[99.5,100.0]% TB hash avg chain 22.070 buckets. Histogram: [15.0,16.7)|??????????|[30.3,32.0] Suggested-by: Richard Henderson Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota --- translate-all.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/translate-all.c b/translate-all.c index 5357737..c8074cf 100644 --- a/translate-all.c +++ b/translate-all.c @@ -1667,6 +1667,10 @@ void dump_exec_info(FILE *f, fprintf_function cpu_fprintf) int i, target_code_size, max_target_code_size; int direct_jmp_count, direct_jmp2_count, cross_page; TranslationBlock *tb; + struct qht_stats hst; + uint32_t hgram_opts; + size_t hgram_bins; + char *hgram; target_code_size = 0; max_target_code_size = 0; @@ -1717,6 +1721,38 @@ void dump_exec_info(FILE *f, fprintf_function cpu_fprintf) direct_jmp2_count, tcg_ctx.tb_ctx.nb_tbs ? (direct_jmp2_count * 100) / tcg_ctx.tb_ctx.nb_tbs : 0); + + qht_statistics_init(&tcg_ctx.tb_ctx.htable, &hst); + + cpu_fprintf(f, "TB hash buckets %zu/%zu (%0.2f%% head buckets used)\n", + hst.used_head_buckets, hst.head_buckets, + (double)hst.used_head_buckets / hst.head_buckets * 100); + + hgram_opts = QDIST_PR_BORDER | QDIST_PR_LABELS; + hgram_opts |= QDIST_PR_100X | QDIST_PR_PERCENT; + if (qdist_xmax(&hst.occupancy) - qdist_xmin(&hst.occupancy) == 1) { + hgram_opts |= QDIST_PR_NODECIMAL; + } + hgram = qdist_pr(&hst.occupancy, 10, hgram_opts); + cpu_fprintf(f, "TB hash occupancy %0.2f%% avg chain occ. Histogram: %s\n", + qdist_avg(&hst.occupancy) * 100, hgram); + g_free(hgram); + + hgram_opts = QDIST_PR_BORDER | QDIST_PR_LABELS; + hgram_bins = qdist_xmax(&hst.chain) - qdist_xmin(&hst.chain); + if (hgram_bins > 10) { + hgram_bins = 10; + } else { + hgram_bins = 0; + hgram_opts |= QDIST_PR_NODECIMAL | QDIST_PR_NOBINRANGE; + } + hgram = qdist_pr(&hst.chain, hgram_bins, hgram_opts); + cpu_fprintf(f, "TB hash avg chain %0.3f buckets. Histogram: %s\n", + qdist_avg(&hst.chain), hgram); + g_free(hgram); + + qht_statistics_destroy(&hst); + cpu_fprintf(f, "\nStatistics:\n"); cpu_fprintf(f, "TB flush count %d\n", tcg_ctx.tb_ctx.tb_flush_count); cpu_fprintf(f, "TB invalidate count %d\n",