From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=148.163.156.1 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796051981; b=SVZ2Mrj4HbtXyrmT3wCebchGVUMgbCpx2KSIE/rQWLeQIqZKQLn//VFsB58sMafrU3zO DWZxx17zynhQklAIqzB7k/Yw+blix9SrvzWV5Vnwdht2KnVRbK61CSIWCJF8l3WxTAhao PQfSGx9xzS2PMV+TUPmBoEueuOn6QR6FOhWSvSQrjHFKpXbdLwPUNVHRoVYCV7tUvHvtj NsanytTPOCjR+Gu99efR4TRdq5KrxgHcwc2wFXe2DuSy5D/+PrrSsGEPaJTn5Ys84i+1O 1ktO0mFRh93uXimXGiw5xA/NWOVnfg5OigCp00BPHmLsr6qNlVAMPBmlkPLbo7xRvXg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796051981; h=DMARC-Filter:Received:DKIM-Signature:Received:Received:Received: Received:Received:Received:Received:Content-Type:Mime-Version:Subject: From:In-Reply-To:Date:Cc:Content-Transfer-Encoding:Message-Id: References:To:X-Mailer:X-TM-AS-GCONF:X-Proofpoint-Reinject: X-Proofpoint-Spam-Info:X-Proofpoint-ORIG-GUID:X-Proofpoint-GUID: X-Authority-Analysis:X-Proofpoint-Spam-Details-Enc: X-Proofpoint-Virus-Version:X-Proofpoint-Spam-Details; bh=LyMn0TB3C4DylW1jfHCgb29lCRChkhk+Huxru52Qmm8=; b=RjgCsaPAiVkhjPJ2sdGWCwIiSBjaxsN+RF5tsq0plTtGvlc/olDnUtvHp0fVO26wssjD rZkwKknYccSJnsNqDidT2/i1iGUuMbRUiIeTALVE07Sb2/nXvMXf1CDn+HUdo1YOoegIn FCXBoIYX0/S+Uu1nfq8hxA+Y5LHJQj/Ml/8knyV5oe2ttP7KDzqsF79dr3TPUynYfOUJF yl5n9ZuNmqc9PBVNd7reqjPuj0qAaMc4/kaSwBCleS5MrzUR7zvGz8MB+P4s4VQ17+qCt 5qjNdxmcIsAcpFiL5OJZBFXbUyA3+Fdy7jx2yOFJJU72ksWzlH/lGN61OdN1f1s1/Gw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b="L0/9myiK"; arc=none smtp.remote-ip=148.163.156.1 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DF64C606A31C; Mon, 30 Nov 2026 15:19:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org DF64C606A31C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=L0/9myiK Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6AUDYg4n3412836; Mon, 30 Nov 2026 15:19:14 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pp1; bh=LyMn0T B3C4DylW1jfHCgb29lCRChkhk+Huxru52Qmm8=; b=L0/9myiKYaIbQfErcsRayk Yksj6bhMJkKGFIEava0FenrHec/nFHfzCVMgs+KK3M/w8XH0LfnIQIR/oMl/o4CW 2tSXgRZcP3yh/J+F8Q/lnVkhDQa3L5eMvfjDoemt+pX5+q01G6Bnj/Z68Gk4VuF6 jIawsBBagVQHk64nit1ECkUO3kPH3KacO9L+EDAwlW8brfRCRKTvxvfHh+Vk/Ow7 4G83Ym1KrNql38vM+nKhPSySy4eWsSHyNM5wMdr27nooWEn7AZvLwUMCYAFTEjjb Nnxw+URVGWeBWxvpqIb8AnerybGI+3lZ67/qWEU2UBSZNqWkz7vYpAOVIgNCIT3w == Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4j7pf3rfa2-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 30 Nov 2026 15:19:13 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 6AUDJTYs1458182; Mon, 30 Nov 2026 15:19:12 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4j8a9jwcy3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Nov 2026 15:19:12 +0000 (GMT) Received: from smtpav07.fra02v.mail.ibm.com (smtpav07.fra02v.mail.ibm.com [10.20.54.106]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6AUFJAkZ42729946 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 30 Nov 2026 15:19:10 GMT Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5697F20065; Mon, 30 Nov 2026 15:19:10 +0000 (GMT) Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 200B820040; Mon, 30 Nov 2026 15:19:07 +0000 (GMT) Received: from smtpclient.apple (unknown [9.124.208.233]) by smtpav07.fra02v.mail.ibm.com (Postfix) with ESMTPS; Mon, 30 Nov 2026 15:19:06 +0000 (GMT) Content-Type: text/plain; charset=utf-8 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.300.41.1.7\)) Subject: Re: [PATCH v2 00/10] perf jevents: Block-indexed string compression and default JEVENTS_ARCH=all From: Athira Rajeev In-Reply-To: Date: Mon, 30 Nov 2026 20:48:54 +0530 Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Jiri Olsa , Adrian Hunter , James Clark , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Message-Id: <1F17F0EC-38CF-471D-BBD1-28663CC70F19@linux.ibm.com> References: <20261116070038.2968725-1-irogers@google.com> To: Ian Rogers X-Mailer: Apple Mail (2.3864.300.41.1.7) X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Proofpoint-Spam-Info: AW1haW4tMjYxMTMwMDA2MCBTYWx0ZWRfX77Y7Ax+IrIjM 5oZOR6crd+KD1gjo1QMvQWcHPRynV7bBECHyi74CFigIMAoQg1nHx3JbJqTSW67yl2ri8RBdKo1 o/u/ksXWfOjhyMHL5ftXt/KVpzowrHs= X-Proofpoint-ORIG-GUID: AC6hd5PjH-Fx2l3k6i4kV_BhkjoaG4Bo X-Proofpoint-GUID: -ZypbSyLqCz8SgDBx7RK89QGpttvCsUU X-Authority-Analysis: v=2.4 cv=R6eWitRX c=1 sm=1 tr=0 ts=6b0d93f2 cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=IkcTkHD0fZMA:10 a=zJRp6_cAMcgA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=iQ6ETzBq9ecOQQE5vZCe:22 a=c92rfblmAAAA:8 a=1XWaLZrsAAAA:8 a=VnNF1IyMAAAA:8 a=nbjQ6-QBJwm0k0x-7GEA:9 a=QEXdDO2ut3YA:10 a=GvGzcOZaWPEFPQC_NcjD:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTMwMDA2MCBTYWx0ZWRfX+6IIQmqIx7Ka VK3cAxQLTLE3HdubQQS18nrLiAMf4o8VBrI3BKAu1xK+08F4NIUMZxeYMzYAt65zEWnzlrfi7M6 q3ZHEJUF2gatjmzNjJGtgV8I8nMgYzmYfnCmpU30dNLHCGAdAVTKusY/Jpa/Uny/hpMdELoS2gL NYP7PCd5M9nH59zKWpGMJN61VnNjuPCiKR/lYGdlpUYJVdA647yUG4/xWkdCkFtndbJvbJPj4Wa 8j0NiFg+uz1RT1THCwr+gpHBDuR3rdKrWrZ6u5WtvcjgTRebicmKFhmzu95ndTkRpVwAkYKIjR0 qNW9hw1pBFYCMry0fbv/zvcjXGxwY7Kb7KRc5sk6QZrW+10uIXgDhq1VKcSn4u/MdO7L5ICNkY5 YvsHu5wWXKf37DLgDC+LGGgXvvvvBCeRoUNPbJrpYzJy4r7F0k5sjLDa2ir2ZAvhJ0lBa4+ixrl h/nL5xMp4AGSu/9l70A== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-11-30_04,2026-11-27_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 priorityscore=1501 adultscore=0 spamscore=0 bulkscore=0 phishscore=0 suspectscore=0 malwarescore=0 clxscore=1015 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2611300060 > On 30 Nov 2026, at 6:07=E2=80=AFAM, Ian Rogers = wrote: >=20 > On Wed, Nov 25, 2026 at 9:41=E2=80=AFAM Athira Rajeev = wrote: >>=20 >>> On 25 Nov 2026, at 3:22=E2=80=AFAM, Ian Rogers = wrote: >>>=20 >>> On Sun, Nov 15, 2026 at 11:00=E2=80=AFPM Ian Rogers = wrote: >>>>=20 >>>> Compiled-in PMU event and metric tables (pmu-events-in.o) currently >>>> store ~6.9 MiB of uncompressed string data in .rodata on x86 alone, >>>> causing JEVENTS_ARCH to default to $(SRCARCH) rather than all and >>>> preventing out-of-the-box cross-architecture perf.data event/metric >>>> resolution unless explicitly built with JEVENTS_ARCH=3Dall. >>>>=20 >>>> Compressing big_c_string as a single whole-table stream would force = perf >>>> to allocate and decompress megabytes of unused CPU models' strings = on >>>> startup just to resolve a single event, whereas compressing = individual >>>> short strings suffers from poor compression ratios and per-string >>>> framing overhead. >>>>=20 >>>> Instead, this series introduces "block-indexed string compression": >>>> sorted, suffix-folded event and metric byte records are packed into >>>> ~8 KiB blocks without splitting records across block boundaries, = each >>>> block is compressed independently (sharing a single preset or = trained >>>> dictionary across blocks so ~8 KiB blocks retain high compression >>>> ratios), and every uint32_t string offset is encoded as >>>> (block_id << 16) | sub_offset. An ~8 KiB target block size sits at = the >>>> knee of the compression vs. random-access curve (smaller 1-4 KiB = blocks >>>> pay 22-128% more .rodata for per-block entropy headers and index >>>> entries, while larger 16-64 KiB blocks yield <15% extra savings at = 2-8x >>>> higher decompression and page-fault cost per binary-search probe). = At >>>> runtime, pmu_events__get_string() uses a lock-free atomic block = pointer >>>> cache to decompress only the touched ~8 KiB blocks on demand, = leaving >>>> untouched CPU models' and non-host architectures' blocks compressed = in >>>> .rodata at zero runtime CPU or heap cost. >>>>=20 >>>> The series starts with a standalone BigCString raw-byte fix for >>>> describe_metricgroup() binary-search ordering, prepares the string = and >>>> PMU table layout, adds the zlib, lzma, and zstd block compression >>>> backends, and switches the default JEVENTS_ARCH to all: >>>>=20 >>>> - Bug fix, string layout, and hot-path isolation (Patches 1-4): >>>> - Patch 1 stores raw NUL-delimited UTF-8 bytes in BigCString = instead >>>> of C-escaped strings, fixing suffix folding and = describe_metricgroup() >>>> binary-search ordering on prefix-overlapping names (such as "Bad" = vs >>>> "BadSpec"; Fixes: 66c6e0c10027) without changing = empty-pmu-events.c >>>> so it can be cherry-picked standalone. >>>> - Patch 2 partitions non-folded BigCString event strings before = metric >>>> strings and sorts entries lexicographically by their raw UTF-8 = byte >>>> sequence within each partition so identically prefixed event = names, >>>> encodings, descriptions, and metric expressions cluster into >>>> adjacent ~8 KiB blocks, improving block compression ratios by >>>> ~20-23%. >>>> - Patch 3 stores PMU names directly as const char *pmu_name string >>>> literals in struct pmu_table_entry (only 68 unique PMU names / = 536 B >>>> across ~443 rows across all architectures, already in = .data.rel.ro) >>>> so the compiler/linker merge them in .rodata.str1.1 and hot PMU >>>> wildcard scans never touch big_c_string or trigger block >>>> decompression. >>>> - Patch 4 encapsulates big_c_string offset lookups behind >>>> pmu_events__get_string(uint32_t offset) across pmu-events.c and >>>> pmu-events-string.c. >>>> - On-demand block decompression backends (Patches 5-8): >>>> - Patch 5 packs big_c_string into ~8 KiB record-aligned blocks = indexed >>>> by (block_id << 16) | sub_offset, adds lock-free thread-safe = atomic >>>> per-block decompression on demand, and adds --compress=3Dzlib = using >>>> raw Deflate with a <=3D 32 KiB preset dictionary. >>>> - Patch 6 adds --compress=3Dlzma using raw LZMA2 per block with a = 64 KiB >>>> dictionary window. >>>> - Patch 7 adds --compress=3Dzstd using ZSTD_decompress_usingDDict() = per >>>> block with a once-digested shared 64 KiB ZSTD_DDict (~26% smaller >>>> .rodata than dictionary-free ~8 KiB zstd blocks). >>>> - Patch 8 wires JEVENTS_COMPRESS into Makefile.perf and >>>> pmu-events/Build, preferring zstd, then zlib, then lzma, and = falling >>>> back to none. >>>> - Testing and JEVENTS_ARCH=3Dall default (Patches 9-10): >>>> - Patch 9 adds prefix-overlapping metricgroups.json test coverage = and >>>> an 8-thread concurrent event/metric/metricgroup stress test in >>>> perf test pmu-events. >>>> - Patch 10 switches the default JEVENTS_ARCH to all. Bundling all >>>> architectures (x86, arm64, powerpc, riscv, s390, nds32) with zstd >>>> shrinks pmu-events-in.o from 7.16 MiB (x86 + none) to 1.11 MiB >>>> (all + zstd, -84.5%) and cuts the stripped perf binary from >>>> 13.32 MiB to 7.28 MiB (-45.4%), with ~3 ms median wall-clock >>>> overhead on 'perf stat true'. >>>=20 >>> Ping. Sashiko reviewed the patches, and they are clean: >>> = https://sashiko.dev/#/patchset/20261116070038.2968725-1-irogers%40google.c= om >>> The series adds a small decompression cost but yields much smaller >>> binaries and cross-architecture JSON event/metric support (still >>> optional but defaulted on given the cost is now minimal). >>=20 >> Hi Ian >>=20 >> I have an observation while trying this on powerpc. >>=20 >> =E2=80=9Cmake=E2=80=9D is picking all arch, logs showed json under = pmu-events/arch/x86 and other arch as well which is good. >> But perf list on powerpc shows "Memory_BW: [Grouping from Top-down = Microarchitecture Analysis Metrics spreadsheet]=E2=80=9D >>=20 >> Below iis difference in =E2=80=9Cperf list=E2=80=9D, without/with = this patchset: >>=20 >> --- cmp1 2026-11-25 17:24:21.433570078 -0500 >> +++ cmp2 2026-11-25 17:24:29.133570078 -0500 >> @@ -31,7 +31,7 @@ Instruction_Stats >> LOCAL_NODE_PUMP_RETRY_RATIO_P01 >> LOCAL_NODE_PUMP_RETRY_RATIO_P23 >> Memory >> -Memory_BW >> +Memory_BW [Grouping from Top-down Microarchitecture Analysis Metrics = spreadsheet] >> Others >> PowerBUS_Frequency >> REMOTE_NODE_PUMPS_RETRIES_RATIO_P01 >>=20 >> powerpc's nest_metrics.json uses Memory_BW with no description of its = own, so I think it picks up x86=E2=80=99s. >> Do we need update in describe_metricgroup() to handle this Ian ? >>=20 >> Note: While trying this on top of tmp.perf-tools-next, patch 8 and = patch 10 has conflict on =E2=80=99tests/make=E2=80=9D, I applied it. >=20 > Hi Athira, >=20 > That looks like a bug in how we are handling metric group descriptions > when they are shared across architectures. Since the description is > being picked up from x86, we should update describe_metricgroup() to > ensure it only uses the description if it's explicitly defined for > that architecture or handle the overlap more gracefully. I'll look > into a fix for this. >=20 > Thanks for catching this and letting me know! I'll also address the > merge conflict. >=20 > Thanks, > Ian Hi Ian, Thanks for confirming and for looking into the fix. I will look out for v3 and test it on powerpc once you post it. Thanks, Athira >=20 >>>=20 >>> Thanks, >>> Ian