Re: [PATCH] branch: avoid slow strvec Coccinelle matching

Taylor Blau <[email protected]>
Newsgroups org.kernel.vger.git
Message-ID <amPXKfnoTzUuuyMN@com-79390>
On Fri, Jul 24, 2026 at 08:27:06AM -0700, Junio C Hamano wrote:
> [email protected] writes:
>
> > From: Ted Nyman <[email protected]>
> >
> > The --delete-merged implementation declares a loop index at function
> > scope and reuses it to walk its strvec of upstreams and its list of
> > candidate branches. Coccinelle 1.1.1 spends hours matching this against
> > the separate_loop_index rule in tools/coccinelle/strvec.cocci, causing
> > the static-analysis job on 'seen' to reach its six-hour timeout.
> > ...
> > The CI failure reproduces locally with Coccinelle 1.1.1: applying
> > strvec.cocci to the original builtin/branch.c still times out with
> > "spatch --timeout 120". With this change, the same check completes in
> > 0.06 seconds.
>
> Impressive.  Nicely analyzed.
>
> Even though this is very much like bending the code only to appease
> the checker, the resulting code is arguably better in this
> particular case, so I do not feel as bad as I have on other
> occasions when we had to work around deficiencies in our tools [*].

Agreed. I don't think we should ever bend over backwards to appease a
static analysis tool, *especially* when it results in worse looking
code. But this case is a strict improvement, and just so happens to
address the Coccinelle issue. ;-)

> I see Harald already took this in the latest update.  Thanks for
> working well together.

Yup. Thanks, both.

Thanks,
Taylor
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.