public inbox for cocci@systeme.lip6.fr
 help / color / mirror / Atom feed
* [cocci] Multiple returns significant performance impact
@ 2024-10-24 11:56 Derek M Jones
  2024-10-24 12:42 ` Markus Elfring
  2024-10-24 14:48 ` Julia Lawall
  0 siblings, 2 replies; 39+ messages in thread
From: Derek M Jones @ 2024-10-24 11:56 UTC (permalink / raw)
  To: cocci

All,

I'm interested in finding the start/end line of
functions, and the pattern below does this.
However, return statements cause multiple matches to
occur.  For instance, in the following code the python
in the cocci script below is called twice.
This is not a problem because I can filter on the
highest line number.

The real problem is the performance hit.  Matching
a function containing lots of returns takes forever (there
are lots of these in the Linux kernel).  I am regularly
seeing timeouts after 600 seconds (the specified timeout).

Is here a way of improving performance, given that I am
not interested in the returns?

void f2(int a)
{
a++;
if (g)
    {
    a++;
    return;
    }
}


@ func_def
@
identifier f;
parameter list parms;
position p_1, p_2;
@@
f(parms)
{@p_1
...
}@p_2
@

script:python @ func << func_def.f;
                 parm_n << func_def.parms;
                 loc_1 << func_def.p_1;
                 loc_2 << func_def.p_2;
               @@

import sys
def printf(format, *args):
     sys.stdout.write(format % args)

printf("%s,func", loc_1[0].file)
printf(",%s", func)
printf(",\"%s\"", parm_n)
printf(",%s,%s", loc_1[0].line, loc_1[0].column)
printf(",%s,%s\n", loc_2[0].line, loc_2[0].column)


int g;

void f1(int a)
{
a++;
}


void f2(int a)
{
a++;
if (g)
    {
    a++;
    return;
    }
}

tfunc.c,func,f1,int a,5,0,7,0
tfunc.c,func,f2,int a,11,0,17,3
tfunc.c,func,f2,int a,11,0,18,0

-- 
Derek M. Jones           Evidence-based software engineering
blog:https://shape-of-code.com


^ permalink raw reply	[flat|nested] 39+ messages in thread

end of thread, other threads:[~2024-10-31  7:51 UTC | newest]

Thread overview: 39+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-24 11:56 [cocci] Multiple returns significant performance impact Derek M Jones
2024-10-24 12:42 ` Markus Elfring
2024-10-24 14:48 ` Julia Lawall
2024-10-24 15:23   ` Derek M Jones
2024-10-24 15:29     ` Julia Lawall
2024-10-24 15:35       ` Derek M Jones
2024-10-24 15:38         ` Julia Lawall
2024-10-24 15:44           ` Victor Gambier
2024-10-24 16:00             ` Julia Lawall
2024-10-24 15:50           ` Derek M Jones
2024-10-24 16:07             ` Markus Elfring
2024-10-24 16:14               ` Julia Lawall
2024-10-24 16:48             ` Markus Elfring
2024-10-24 17:30             ` Derek M Jones
2024-10-24 18:26               ` Markus Elfring
2024-10-24 21:03                 ` Derek M Jones
2024-10-25  5:38                   ` Markus Elfring
2024-10-25 11:54                     ` Derek M Jones
2024-10-27 12:48                     ` [cocci] Broken code block size determination in function implementations Markus Elfring
2024-10-27 13:31                       ` Julia Lawall
2024-10-27 15:15                         ` Markus Elfring
2024-10-27 16:40                         ` Markus Elfring
2024-10-27 17:05                           ` Julia Lawall
2024-10-27 17:28                             ` Markus Elfring
2024-10-27 17:34                               ` Julia Lawall
2024-10-27 17:45                                 ` Markus Elfring
2024-10-27 17:55                                   ` Julia Lawall
2024-10-27 18:04                                     ` Markus Elfring
2024-10-27 18:00                                   ` Derek M Jones
2024-10-27 18:11                                     ` [cocci] Evolving experiences from evidence-based software engineering Markus Elfring
2024-10-28  9:00                               ` [cocci] Searching for macro calls besides function implementations (with SmPL)? Markus Elfring
2024-10-28 12:57                                 ` Julia Lawall
2024-10-28 10:44                             ` [cocci] Broken code block size determination in function implementations Markus Elfring
2024-10-29 12:17                             ` Markus Elfring
2024-10-31  7:50                             ` Markus Elfring
2024-10-26 11:43             ` [cocci] Checking SmPL run time characteristics for code block position " Markus Elfring
2024-10-24 16:16           ` [cocci] SmPL position variables … Markus Elfring
2024-10-24 16:20             ` Julia Lawall
2024-10-24 16:28               ` Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox