From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 26A9B43E9C; Thu, 18 Apr 2024 08:41:32 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A1F374014F; Thu, 18 Apr 2024 08:41:31 +0200 (CEST) Received: from mail-ej1-f49.google.com (mail-ej1-f49.google.com [209.85.218.49]) by mails.dpdk.org (Postfix) with ESMTP id 595AC40042 for ; Thu, 18 Apr 2024 08:41:30 +0200 (CEST) Received: by mail-ej1-f49.google.com with SMTP id a640c23a62f3a-a5568bef315so105228866b.1 for ; Wed, 17 Apr 2024 23:41:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pantheon.tech; s=google; t=1713422490; x=1714027290; darn=dpdk.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=FmLzK9vAMApwM7AZMqfiwa1mTVmRJNBdcWNgBAOEil4=; b=sGcMMcOSlHw4VJFdb/fwlLGy2giSOf+vg5sd0WI+6infEFQ90W2ZQpP+ZwgmW6/9Bw 3AxLYzJDMQDWEaCL6HgsBQ7gMeUWWEwCfLe4ubKp7Efl5e+oiSoj9TteTpXwISegUcIr scujrqOnM21JGczSiTRTJ969LL+xjDN5vSQoKsCxmtZRqERw5N5LUiOrwvjdQOFRNp1v wQLGQ0FSt+QsRa7M3eeYxJaaseR5N6oXxCQUKXBYSkl8zC2xEWO2KpWkmIxr0JAyh86x /9yo4EIhZIxPxwW+53Pr0zhCblPoUXQh8QCGM67NvQQTT5kj3MdBWr88ISxTAt4YUUR+ x24w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713422490; x=1714027290; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FmLzK9vAMApwM7AZMqfiwa1mTVmRJNBdcWNgBAOEil4=; b=tDEC2mmtDXKZ+NGXLAsIILtPbcMiAdxcPhBmRrGMZVQGRk5GJvbos4qITrJfKPGHTE hNFbI6yQu1+fiEk3ARQXCRKMpaADaDq48RY7aXP3FhmzUGfmXOfCAgPXsJ5xB3C4JMqr PRcjpZuxsGZr7w/JYz0nA/OfnFYCdteMSb621OBwAAGR6yYI0CBy5zSBwAyJ6GpwsFvh r3h/+1/Jp0SkWSYhwt3ZVkUh3eEm0u0wCD+/aGRQJz3FNRI4u4IcYbBmIx1AEMZznkru B/2OyfKHKS+IkXJeFSItbQCRWzDh7kui5VkaSms6VmTTt1dU+DXSAa12PZygI7dLxX/m D96g== X-Gm-Message-State: AOJu0Yxp/rgRTVyMTtJH6VCzSA9f7pFLyrsFWQTT2LYxQ7UQj3yudLAo gSN3cXJUJ4wrX0tZHsPOXS57bdV5hVrqG6psOKMK5yYdSM+gmEvKHpWRarz5EVBX/N0T0BSdUnT 5E7+5RHn5NspxiN9/LCt2J9hNiqbXH+UoAuG+9w== X-Google-Smtp-Source: AGHT+IGM30F5pmR+ycmXTdc//xjmMLJMe4SDSc67ZBwZxQ0y4qpQOQTBFr4Cgxb80IZU4JFipyPZSlG/1H5Cdr5+wlQ= X-Received: by 2002:a17:906:c214:b0:a52:4edf:cc3 with SMTP id d20-20020a170906c21400b00a524edf0cc3mr1099455ejz.11.1713422489936; Wed, 17 Apr 2024 23:41:29 -0700 (PDT) MIME-Version: 1.0 References: <20240412111136.3470304-1-luca.vizzarro@arm.com> <20240412111136.3470304-5-luca.vizzarro@arm.com> <4f17ef06-c508-495a-a0f8-a28e9e77a1f9@arm.com> <68da0ef2-430b-42af-8c1d-026760cfa4f1@arm.com> <7165977f-6371-4398-b34d-eaeeaa1ef379@arm.com> In-Reply-To: <7165977f-6371-4398-b34d-eaeeaa1ef379@arm.com> From: =?UTF-8?Q?Juraj_Linke=C5=A1?= Date: Thu, 18 Apr 2024 08:41:19 +0200 Message-ID: Subject: Re: [PATCH 4/5] dts: add `show port info` command to TestPmdShell To: Luca Vizzarro Cc: dev@dpdk.org, Jeremy Spewock , Paul Szczepanek Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Wed, Apr 17, 2024 at 5:29=E2=80=AFPM Luca Vizzarro wrote: > > On 17/04/2024 15:25, Luca Vizzarro wrote: > > On 17/04/2024 14:22, Juraj Linke=C5=A1 wrote: > >>> I'll > >>> experiment with some look ahead constructs. The easiest solution is t= o > >>> match everything that is not * ([^*]+) but can we be certain that the= re > >>> won't be any asterisk in the actual information? > >> > >> We can't. But we can be reasonably certain there won't be five > >> consecutive asterisks, so maybe we can work with that. > > > > We can work with that by using look ahead constructs as mentioned, whic= h > > can be quite intensive. For example: > > > > /(?<=3D\n\*).*?(?=3D\n\*|$)/gs > > > > looks for the start delimiter and for the start of the next block or th= e > > end. This works perfectly! But it's performing 9576 steps (!) for just > > two ports. The current solution only takes 10 steps in total. > > Thinking of it... we are not really aiming for performance, so I guess > if it simplifies and it's justifiable, then it's not a problem. > Especially since this command shouldn't be called continuosly. > We have to weigh the pros and cons on an individual basis. In this case, the output is going to be short so basically any solution is going to be indistinguishable from any other, performance wise. > The equivalent /\n\*.+?(?=3D\n\*|$)/gs (but slightly more optimised) take= s > approximately 3*input_length steps to run (according to regex101 at > least). If that's reasonable enough, I can do this: > > iter =3D re.finditer(input, "\n\*.+?(?=3D\n\*|$)", re.S) > return [TestPmdPortInfo.parse(match.group(0)) for match in iter] > > Another optimization is artificially adding a `\n*` delimiter at the end > before feeding it to the regex, thus removing the alternative case (|$), > and making it 2*len steps: > > input +=3D "\n*" > iter =3D re.finditer(input, "\n\*.+?(?=3D\n\*)", re.S) > return [TestPmdPortInfo.parse(match.group(0)) for match in iter] > I like this second one a bit more. How does the performance change if we try to match four asterisks "\n\****.+?(?=3D\n\****)"? Four asterisks shouldn't randomly be in the output as that's basically another delimited. And we should document this in the docstring - sample output, then explain the extra characters and the regex itself. We shouldn't forget this in the other commit as well (show port stats). > Let me know what you think! > > Best, > Luca