From: Jeremy Spewock <jspewock@iol.unh.edu>
To: Luca Vizzarro <Luca.Vizzarro@arm.com>
Cc: yoan.picchi@foss.arm.com, probb@iol.unh.edu,
paul.szczepanek@arm.com, npratte@iol.unh.edu,
thomas@monjalon.net, Honnappa.Nagarahalli@arm.com,
juraj.linkes@pantheon.tech, wathsala.vithanage@arm.com,
dev@dpdk.org
Subject: Re: [PATCH v2 1/1] dts: add text parser for testpmd verbose output
Date: Fri, 2 Aug 2024 09:35:13 -0400 [thread overview]
Message-ID: <CAAA20UReuno73q7y_v0tHzz7-dxOGeGUbwUfi=uq9eX8V53fNg@mail.gmail.com> (raw)
In-Reply-To: <e710dfb1-a990-443b-94ed-0dc55e5624a7@arm.com>
On Thu, Aug 1, 2024 at 4:41 AM Luca Vizzarro <Luca.Vizzarro@arm.com> wrote:
>
> Great work Jeremy! Just a couple of minor passable improvement points.
>
> On 30/07/2024 14:34, jspewock@iol.unh.edu wrote:
>
> > +@dataclass
> > +class TestPmdVerbosePacket(TextParser):
> > + """Packet information provided by verbose output in Testpmd.
> > +
> > + The "receive/sent queue" information is not included in this dataclass because this value is
> > + captured on the outer layer of input found in :class:`TestPmdVerboseOutput`.
> > + """
> > +
> > + #:
> > + src_mac: str = field(metadata=TextParser.find(r"src=({})".format(REGEX_FOR_MAC_ADDRESS)))
> Just a(n optional) nit: TextParser.find(f"src=({REGEX_FOR_MAC_ADDRESS})")
> The raw string is only needed to prevent escaping, which we don't do here.
Ack. I really just left it this way because it also adjusts
highlighting in some IDEs, but there isn't much to see here anyway.
> > + #:
> > + dst_mac: str = field(metadata=TextParser.find(r"dst=({})".format(REGEX_FOR_MAC_ADDRESS)))
> As above.
Ack.
> > + #: Memory pool the packet was handled on.
> > + pool: str = field(metadata=TextParser.find(r"pool=(\S+)"))
> > + #: Packet type in hex.
> > + p_type: int = field(metadata=TextParser.find_int(r"type=(0x[a-fA-F\d]+)"))
> > + #:
>
> <snip>
>
> > + @staticmethod
> > + def extract_verbose_output(output: str) -> list[TestPmdVerboseOutput]:
> > + """Extract the verbose information present in given testpmd output.
> > +
> > + This method extracts sections of verbose output that begin with the line
> > + "port X/queue Y: sent/received Z packets" and end with the ol_flags of a packet.
> > +
> > + Args:
> > + output: Testpmd output that contains verbose information
> > +
> > + Returns:
> > + List of parsed packet information gathered from verbose information in `output`.
> > + """
> > + iter = re.finditer(r"(port \d+/queue \d+:.*?(?=port \d+/queue \d+|$))", output, re.S)
>
> How about using a regex that matches what you described? ;) Keeping re.S:
>
> (port \d+/queue \d+.+?ol_flags: [\w ]+)
>
> Would spare you from using complex lookahead constructs and 4.6x less
> steps. Maybe it doesn't work with every scenario? Looks like it works
> well with the sample output I have. Let me know if it works for you.
>
I tried using something like this actually which is probably why the
docstring reflects that type of language, but I didn't use it because
it doesn't match one specific case. I'm not sure how common it is, and
I haven't seen it happen in my recent testing, but since the verbose
output specifically states that it sent/received X number of packets,
I presume there is a case where that number will be more than 1, and
there will be more than one set of packet information after that first
line. I think I've seen it happen in the past, but I couldn't recreate
it in testing.
For context to this next section, if it wasn't clear, I consider the
`port \d+/queue \d+` line to be the header line and the start of a
"block" of verbose output.
Basically though the problem with this is that if there are more than
one packet under that header line, the lazy approach will only consume
up until the ol_flags of the first packet of a block, and the greedy
approach consumes everything until the last packet of the entire
output. You could use the lazy approach with the next port/queue line
as your delimiter, but then the opening line of the next block of
output is included in the previous block's group. The only way I could
find to get around this and go with the idea of "take everything from
the start of this group until another group starts" but without
capturing the opening of the next block was a look ahead. Again
though, I definitely don't love the regex that I wrote and would love
to find a better alternative.
> Best,
> Luca
>
next prev parent reply other threads:[~2024-08-02 13:35 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-29 20:39 [PATCH v1 0/1] dts: testpmd verbose parser jspewock
2024-07-29 20:39 ` [PATCH v1 1/1] dts: add text parser for testpmd verbose output jspewock
2024-07-30 13:34 ` [PATCH v2 0/1] dts: testpmd verbose parser jspewock
2024-07-30 13:34 ` [PATCH v2 1/1] dts: add text parser for testpmd verbose output jspewock
2024-07-30 15:41 ` Nicholas Pratte
2024-07-30 21:30 ` Jeremy Spewock
2024-08-02 14:54 ` Nicholas Pratte
2024-08-02 17:38 ` Jeremy Spewock
2024-08-05 13:20 ` Nicholas Pratte
2024-07-30 21:33 ` Jeremy Spewock
2024-08-01 8:43 ` Luca Vizzarro
2024-08-02 13:40 ` Jeremy Spewock
2024-08-01 8:41 ` Luca Vizzarro
2024-08-02 13:35 ` Jeremy Spewock [this message]
2024-08-08 20:36 ` [PATCH v3 0/1] dts: testpmd verbose parser jspewock
2024-08-08 20:36 ` [PATCH v3 1/1] dts: add text parser for testpmd verbose output jspewock
2024-08-08 21:49 ` Jeremy Spewock
2024-08-12 17:32 ` Nicholas Pratte
2024-09-09 11:44 ` Juraj Linkeš
2024-09-17 13:40 ` Jeremy Spewock
2024-09-18 8:09 ` Juraj Linkeš
2024-09-18 16:34 ` [PATCH v4 0/1] dts: testpmd verbose parser jspewock
2024-09-18 16:34 ` [PATCH v4 1/1] dts: add text parser for testpmd verbose output jspewock
2024-09-18 17:05 ` [PATCH v5 0/1] dts: testpmd verbose parser jspewock
2024-09-18 17:05 ` [PATCH v5 1/1] dts: add text parser for testpmd verbose output jspewock
2024-09-19 9:02 ` Juraj Linkeš
2024-09-20 15:53 ` Jeremy Spewock
2024-09-23 13:30 ` Juraj Linkeš
2024-09-19 12:35 ` Juraj Linkeš
2024-09-20 15:55 ` Jeremy Spewock
2024-09-25 15:46 ` [PATCH v6 0/1] dts: testpmd verbose parser jspewock
2024-09-25 15:46 ` [PATCH v6 1/1] dts: add text parser for testpmd verbose output jspewock
2024-09-26 8:25 ` Juraj Linkeš
2024-09-26 14:43 ` Jeremy Spewock
2024-09-26 15:47 ` [PATCH v7 0/1] dts: testpmd verbose parser jspewock
2024-09-26 15:47 ` [PATCH v7 1/1] dts: add text parser for testpmd verbose output jspewock
2024-09-27 9:32 ` Juraj Linkeš
2024-09-27 11:48 ` Luca Vizzarro
2024-09-30 13:41 ` Juraj Linkeš
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAAA20UReuno73q7y_v0tHzz7-dxOGeGUbwUfi=uq9eX8V53fNg@mail.gmail.com' \
--to=jspewock@iol.unh.edu \
--cc=Honnappa.Nagarahalli@arm.com \
--cc=Luca.Vizzarro@arm.com \
--cc=dev@dpdk.org \
--cc=juraj.linkes@pantheon.tech \
--cc=npratte@iol.unh.edu \
--cc=paul.szczepanek@arm.com \
--cc=probb@iol.unh.edu \
--cc=thomas@monjalon.net \
--cc=wathsala.vithanage@arm.com \
--cc=yoan.picchi@foss.arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).