From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id kA72DXURt2rnGwUAWB0awg (envelope-from ) for ; Fri, 25 Sep 2026 20:27:33 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=CukPpADL; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 241991E033; Fri, 25 Sep 2026 20:27:33 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_SBL_CSS autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::32]) (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 simark.ca (Postfix) with ESMTPS id E04931E033 for ; Fri, 25 Sep 2026 20:27:31 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3D14C4BB8F7E for ; Sat, 26 Sep 2026 00:27:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3D14C4BB8F7E Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=CukPpADL Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id 838C24BAE7C6 for ; Sat, 26 Sep 2026 00:27:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 838C24BAE7C6 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 838C24BAE7C6 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790382426; cv=none; b=ZAh0efK6qEg5ZUBvY5WZMiaewZ5wYElWC+a7ZPE/nnT0/auJTrpAyzxLLp+IJfDdjFkU4iZy1aqBT0AHUmCOn2c58fnr5qC5wuK/scdZu5TbGmnq2Ch058nPIIBzMgtvPkWM6d9gsk6/PBTUl7Cfr8oK+VPhJL/U9yzTUibIrfo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790382426; c=relaxed/simple; bh=tIHJZxu/+u0mP3YgebwEROa2BLBbdxLPNDlLIDTcxT4=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=wFFIVxMMK/qIe8LCDTB+V7UEPHMGVUk7vzZpUQ/asDI4QZ67AoZkocf+/TQWs9FVfB8z3vLVl4VjxJQHJemZ6Zm/pd/2TcLinMWm3GeCqhp9pElLHkeJRSm9Zi7ENVU6FjMzRD6Q443WqdWInwpR6KllzakS8WV/enmNxTQfGH8= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=CukPpADL DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 838C24BAE7C6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1790382426; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kD43Duijg4QxDTaf3yHVGLPKqcn3lpMN1wgXJVK+LRc=; b=CukPpADLi2YDdep8XadQn9hjPMFOaxLRP1ribPXR5WrApIAL42ZPpH2wp4MWhoFYVsElXa Trg7ydRiTDfdAMZ/BClIdq+uuMDpw/5+jboYeqqqIFN2WWvs69ctfTd+/Ak0g+zUvzoE23 pa2RT+8Y8H+XXcL6IRknhyegR/dFPRY= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-345-PLSZHGhPOH6gAbhcvYS-EA-1; Fri, 25 Sep 2026 20:27:01 -0400 X-MC-Unique: PLSZHGhPOH6gAbhcvYS-EA-1 X-Mimecast-MFC-AGG-ID: PLSZHGhPOH6gAbhcvYS-EA_1790382421 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D4D4E1954203; Sat, 26 Sep 2026 00:27:00 +0000 (UTC) Received: from f44-mesa-1 (unknown [10.22.64.34]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 1A90C195604D; Sat, 26 Sep 2026 00:26:59 +0000 (UTC) Date: Fri, 25 Sep 2026 17:26:57 -0700 From: Kevin Buettner To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: Re: [PATCH] Add QUIT to inner loop in value_print_array_elements Message-ID: <20260925172315.20eb519c@f44-mesa-1> In-Reply-To: <20260922201202.2189948-1-tromey@adacore.com> References: <20260922201202.2189948-1-tromey@adacore.com> Organization: Red Hat MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: nMD2ykn0wVmGO9tcMYoC87Ywbo_WAP64hprOa8X_Vt0_1790382421 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org On Tue, 22 Sep 2026 14:12:02 -0600 Tom Tromey wrote: > When printing an array, some work is done to detect repeated elements. > This work is not interruptible, and it is somewhat slow (see > PR exp/32681). > > This patch adds QUITs to the relevant spots. My AI-enabled patch review workflow confirmed Gwen's finding. It said: Finding 1 -- the dominant uninterruptible loop is in char-print.c, not the array code. I profiled the exact repro from the thread (perf record on a patched build, 8 MiB static char p[], "print p"). 99% of samples are: print_command_1 -> print_value -> value_print -> c_value_print -> c_value_print_array -> printstr -> generic_printstr -> count_next_character -> iterate -> gdb_iconv -> iconv (98.98%) value_print_array_elements never appears. The reason is gdb/c-valprint.c:259: a char array that passes c_textual_element_type is printed through current_language->printstr -- the string path -- which entirely bypasses the code this patch modifies. Two measurements confirm this on the patched build (maint time 1, print elements 10, max-value-size unlimited). A char array of 8 MiB, printed through generic_printstr and iconv, takes 43.3 s. An int array of the same 8 MiB, which goes through value_print_array_elements, takes 0.29 s. So Guinevere's "you may have missed a spot" is correct, and the missed spot is char-print.c:279. The outer loop there, at char-print.c:525, already has a QUIT at line 529, but it only runs once per distinct character -- for a uniform array the inner while (1) consumes all 8M characters inside a single outer iteration, which is why the existing QUIT never fires. The fix is small: event-top.h is already included at char-print.c:21, so adding a QUIT as the first statement of the while (1) body at line 279 would do it, either in this patch or in an immediate follow-up. The commit message might also be softened: "This patch adds QUITs to the relevant spots" reads as a complete fix for the PR 17613 symptom, which it is not. AI model used was GLM 5.3 Flash. It had 3 other findings too, but they were minor. Kevin