| Message ID | 20260103200510.3605009-28-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=1767470835; bh=3pWhcG9T5kW1s64DKpTiaAkADuRCdxzxNf10hr7Mg5Q=; 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=DBQfI6dKr0GVfRp6Wq8Brx9Q3wDyMYKhaiWFDxW9shyDwMomku+KCWx2CPtsyDY/W 1j9FXd7OjEBY1IUBEnIJPF7U4oFsyPiKsgHJIkRnwbCPw89C2PE2RezFP9jj9buV4W Sh/1RfCTinTk7V0sVJAN4XNJMFcx659nkU1PK+95SE7v6FijwaKw1RTsEEYuMFPFEx 2+dCtKBPkEhwqiYm0TuYGaPJFfx8HWiIhmeMlzDaaiU+nOw7f84J890g0B7494RSqJ uFQpG8XvLP2HGLyCBje/MbyBwHNSJwV2oHq+dlgAwbSs2Epy/+DrH8DhWxkrrUUQ4Y RCC0EDg/Ds8zQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9ACBE69095 for <u-boot-concept@u-boot.org>; Sat, 3 Jan 2026 13:07:15 -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 nv1T-bTTNf5I for <u-boot-concept@u-boot.org>; Sat, 3 Jan 2026 13:07:15 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767470835; bh=3pWhcG9T5kW1s64DKpTiaAkADuRCdxzxNf10hr7Mg5Q=; 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=DBQfI6dKr0GVfRp6Wq8Brx9Q3wDyMYKhaiWFDxW9shyDwMomku+KCWx2CPtsyDY/W 1j9FXd7OjEBY1IUBEnIJPF7U4oFsyPiKsgHJIkRnwbCPw89C2PE2RezFP9jj9buV4W Sh/1RfCTinTk7V0sVJAN4XNJMFcx659nkU1PK+95SE7v6FijwaKw1RTsEEYuMFPFEx 2+dCtKBPkEhwqiYm0TuYGaPJFfx8HWiIhmeMlzDaaiU+nOw7f84J890g0B7494RSqJ uFQpG8XvLP2HGLyCBje/MbyBwHNSJwV2oHq+dlgAwbSs2Epy/+DrH8DhWxkrrUUQ4Y RCC0EDg/Ds8zQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8A6B66907B for <u-boot-concept@u-boot.org>; Sat, 3 Jan 2026 13:07:15 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767470833; bh=H0xfTGA0eBn4Rs4ZOzyQjsqzQjlDAK6EZMg0em/gI68=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q48q1A9T8p2l/A5/V+ScqzYklPC0Vq5NOLMIqauivBLrmt9IvOlHUkVi9oVPQjlt/ iv+AsbCq1mC56QUchaKhUlfVuuIAB0AHbX+kcnULOse9DpimnwbG7B8gF56hUQGPyu LPuS6qGdDARvSarmU1cfRTDnNeQB0An8wewaGSycAxQGCBhmdezzP2oPkIbzxtKw7A 9UM1hxzPlCU4f72DQWqgjup1eLY9FD73A8+STyrnLD42vo+OnfNlqXumOKql2XWPfN tL4G9TwWEKOx8LyeuGfnzxPFeYuf2GO1TaeS9r2ObGoxEx5yOntyxTBdrV1UeYlS0K n2I1JahX5QUjg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 906FB68FCC; Sat, 3 Jan 2026 13:07:13 -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 CaNBehkUc-vL; Sat, 3 Jan 2026 13:07:13 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767470829; bh=miwgdPmilFRPYIs/3AaT72uzfJk/vF2C7zVq0jbYYak=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kQLJXObaQVQkpBKC7612Xh30BOBWAnfuaVUVbg647Kq2CqJ3r8gcw8MdrwT+KfTnS h69oInQ0DB8ynIwl6maWAs1QtQguj6nfYTUuZOPDBzjoTGSfWbIMd39WqWjk9NXHrk cerrleB1tNVWNJtBL/G92KvdXaI0u2gIxzuKNo38OMv9oSLpzMcAXe3Xo1BzwpJWNC EXLa0J3OyNxQXi//joe0k7csv0oph6+Ue7/qdp4x0m/ggsIfCs8YvVBelQbpFgYSF8 65NlBNMmyRLraI4pblLblOiE05Vq4zrWBmqwEsCDYffRp967ir3hCqQvyeFTgi520I YZtJ6SraccijQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id EE77269085; Sat, 3 Jan 2026 13:07:08 -0700 (MST) From: Simon Glass <sjg@u-boot.org> To: U-Boot Concept <concept@u-boot.org> Date: Sat, 3 Jan 2026 13:04:58 -0700 Message-ID: <20260103200510.3605009-28-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260103200510.3605009-1-sjg@u-boot.org> References: <20260103200510.3605009-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: BHRIGXON36PQBS5YAQHQGKKSWYXPY3SN X-Message-ID-Hash: BHRIGXON36PQBS5YAQHQGKKSWYXPY3SN 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 v2 27/29] 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/BHRIGXON36PQBS5YAQHQGKKSWYXPY3SN/> 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, 8:04 p.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> --- (no changes since v1) 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()