| Message ID | 20260103011908.149445-23-sjg@u-boot.org |
|---|---|
| State | New |
| Headers |
Return-Path: <concept-bounces+u-boot-concept=u-boot.org@u-boot.org> X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767403241; bh=eXcgJL0olKVhUsEdZYaSPS45Fn3IkMrvT75j4x/S4kE=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=SJK6UyfRyxhJEgJd0bq2FzmhttCVUw2yy0AADN22TvdaoJdymAytG3rslv28iZ3bz 7EmkzKMdedQ2yaYo7iocio+1RWXho8Kx5Crko03Qi9nX8iGwVHnTyegeTSgGS75AqS XbzVxM48LpP3a7ryyRwHra1TuKSypEx958z7X3IyCpYcrIZbASwDSHGf/i5tDu2G4u AtJzi7AuXBMPO3gaiIvBTffr64UIDmHdtiLDE3bIRuhnj/QbFU8X1YojHmNiXMoy6m qEaKhQJUcsh534+2moz/E76zGuYZDhra+ChDp0ncLgH2uLDIkl0OUVOIRWV+eUWI74 5pIYsld070vQg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 49CC56904D for <u-boot-concept@u-boot.org>; Fri, 2 Jan 2026 18:20:41 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id GRC9nQWBEfPs for <u-boot-concept@u-boot.org>; Fri, 2 Jan 2026 18:20:41 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767403241; bh=eXcgJL0olKVhUsEdZYaSPS45Fn3IkMrvT75j4x/S4kE=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=SJK6UyfRyxhJEgJd0bq2FzmhttCVUw2yy0AADN22TvdaoJdymAytG3rslv28iZ3bz 7EmkzKMdedQ2yaYo7iocio+1RWXho8Kx5Crko03Qi9nX8iGwVHnTyegeTSgGS75AqS XbzVxM48LpP3a7ryyRwHra1TuKSypEx958z7X3IyCpYcrIZbASwDSHGf/i5tDu2G4u AtJzi7AuXBMPO3gaiIvBTffr64UIDmHdtiLDE3bIRuhnj/QbFU8X1YojHmNiXMoy6m qEaKhQJUcsh534+2moz/E76zGuYZDhra+ChDp0ncLgH2uLDIkl0OUVOIRWV+eUWI74 5pIYsld070vQg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 38F0B68F8A for <u-boot-concept@u-boot.org>; Fri, 2 Jan 2026 18:20:41 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767403239; bh=PevnMRacnPojIGVkxMRz1zkNZ/BhxAMoX2F0SSBdX58=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KoBuUiU/3hlQvY3JtojeMeg4Mbp9NV++bOJlGbYRydu9URBotGEFabKOxQmtIkDw2 QrllWVUdnKtUE6ndfvAQpCIJognFXIuLFBVHIUkiOZwqdVO9X5y6DifykMabDyvOxm E4bDUMDkVy66AxWPjP3h1qs5ZHvMYiNkw971Poxovx34IYKfOY907IKZeZpH5y0Eeo 6myZ5aOF1fM5jzV7xvgZt4KocaSzCLFHvApgKRpO22DAwjHSmqo0EFbg+RsFLg/1IW QSeiaI3DwLLKnitR5G/MNihAf6dIAeb74KXUMqTGqKSPfioKnrENHo0lXFBMtLJfg2 wTvybkygYJXIQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3B21F68F8A; Fri, 2 Jan 2026 18:20:39 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id 7wZ2rOgZEfj4; Fri, 2 Jan 2026 18:20:39 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767403233; bh=GHdSEpGcH9l+QUhd0bAFyh3Mcvs80BqZ5JD7DByk8qg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uCQjqxhw4U/bpYfnthm1VpnoK6tKOZeC6VtC2vhTc1q3KOPWkIAUmx3Y50t81DhOG HHGVy3EHA3o/F3QWn3voY/XOAG4G3oELRFgjOm539egOJdT85F0X2N+c+32HhHIgki MTTaW9KmVL4tpalKeJdLTcyPjuPxYy0ZMToRpVtkM+7TWSHOXvFkxs8kYdOoVQnq33 0AZcykws3x88ifcFw5hQPbIzE2j1CENCeyi5ckvBkV4YGVrVT8bANV8T3X7mwWOJ41 mr352IxacgUDeU3ztfefhovtxtwQrB3hBwW/puruhN3D3ZwKbhAffW6fZHDZRbYCaA 3QS0bUsxXujPw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 1FF1768BF2; Fri, 2 Jan 2026 18:20:33 -0700 (MST) From: Simon Glass <sjg@u-boot.org> To: U-Boot Concept <concept@u-boot.org> Date: Fri, 2 Jan 2026 18:18:58 -0700 Message-ID: <20260103011908.149445-23-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260103011908.149445-1-sjg@u-boot.org> References: <20260103011908.149445-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: BKFJKLMLRZ4MYL7MDZ5BBWSZKU52H7RR X-Message-ID-Hash: BKFJKLMLRZ4MYL7MDZ5BBWSZKU52H7RR X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt <xypron.glpk@gmx.de>, Simon Glass <simon.glass@canonical.com> X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 22/24] test/py: Speed up VT100-filtering in expect() List-Id: Discussion and patches related to U-Boot Concept <concept.u-boot.org> Archived-At: <https://lists.u-boot.org/archives/list/concept@u-boot.org/message/BKFJKLMLRZ4MYL7MDZ5BBWSZKU52H7RR/> List-Archive: <https://lists.u-boot.org/archives/list/concept@u-boot.org/> List-Help: <mailto:concept-request@u-boot.org?subject=help> List-Owner: <mailto:concept-owner@u-boot.org> List-Post: <mailto:concept@u-boot.org> List-Subscribe: <mailto:concept-join@u-boot.org> List-Unsubscribe: <mailto:concept-leave@u-boot.org> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit |
| Series |
Malloc debugging and test/py improvements
|
|
Commit Message
Simon Glass
Jan. 3, 2026, 1:18 a.m. UTC
From: Simon Glass <simon.glass@canonical.com> The VT100 escape sequence filter is applied to the entire buffer on every read iteration, causing O(n^2) performance. With 1.6MB of output from verbose unit tests and 1KB reads, this results in ~1600 iterations, each processing an ever-growing buffer. Fix this by filtering only the newly received data before appending it to the buffer. To test this, dm_test_host() was modified to do 10 malloc_dump() calls, thus producing a lot of output. The impact of this patch is: total time 6s -> 4.5s total CPU 18s -> 13s Note: Various other approaches were tried, including removing the concatenation to self.buf and updating expect() to only consider recent text. None of these yielded useful results. Signed-off-by: Simon Glass <simon.glass@canonical.com> --- test/py/console_base.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/test/py/console_base.py b/test/py/console_base.py index 6d117413aa3..c4472420c31 100644 --- a/test/py/console_base.py +++ b/test/py/console_base.py @@ -813,11 +813,13 @@ class ConsoleBase(): c = self.p.receive(RECV_BUF_SIZE) if self.logfile_read: self.logfile_read.write(c) - self.buf += c + # Filter VT100 escapes from new data only, not entire buffer. + # This avoids O(n^2) behaviour when receiving large output. # count=0 is supposed to be the default, which indicates # unlimited substitutions, but in practice the version of # Python in Ubuntu 14.04 appears to default to count=2! - self.buf = self.re_vt100.sub('', self.buf, count=1000000) + c = self.re_vt100.sub('', c, count=1000000) + self.buf += c finally: if self.logfile_read: self.logfile_read.flush()