All of lore.kernel.org
 help / color / mirror / Atom feed
* [cocci] Optimizing *.cocci rules by concat'ing them
@ 2022-09-01 15:00 Ævar Arnfjörð Bjarmason
  2022-09-01 15:19 ` Julia Lawall
  2022-09-01 18:12 ` [cocci] Checking consequences from concatenation of SmPL rules Markus Elfring
  0 siblings, 2 replies; 3+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2022-09-01 15:00 UTC (permalink / raw)
  To: Coccinelle ML

Are there reasons for why $subject is a generally bad idea, i.e. given a
set of *.cocci rules in a directory instead of something like:

	for c in cocci/*.cocci
	do
		spatch --sp-file $c --patch . *.c
	done

Doing:

	cat cocci/*.cocci >ALL.cocci
	spatch --sp-file ALL.cocci --patch . *.c

I'm aware that rules in general may rely on previous transformations,
such that the 3rd rule in a file might not fire unless the other 2 have
previously changed the code.

But aside from any such undeclared dependencies, which surely I'll have
trouble with either way. I.e. I'd get to the 2nd rule in A.cocci, apply
that to my sources, and only then on a second run would the 1st rule in
B.cocci fire, but it should have been in A.cocci to begin with, and
depending on the 2nd rule in that file.

Are there reasons for why this is a Bad Idea?

The motivation here (and this is probably burying the lede) is that I
implemented a "spatchcache", which can cache previous runs of "spatch"
in a local Redis (or with a custom command, if you don't have Redis, I
started out with a dumb FS-based cache).

It uses the approach of piggy-backing on GCC and Clang's ability to dump
a full list of all the files that a given *.c file depends on.

This is usually used to drive better incremental "make" support, but I'm
(ab)using it to implement an "spatchcache". If the hash of a the target
file *and* everything it depends on *and* spatch's path, flags etc. is
the same I can cache the output of "spatch".

See [1] for a series to implement this for git.git. I'd previously mused
on this list in [2] about this approach (but hadn't finished it up until
now).

But even then git's fairly slow in running "make coccicheck", and of
course it does nothing to speed up an initial run. So concat'ing the
*.cocci files we use seems like a viable option. But I thought I'd ask
first in case I'm running into somewell-known caveat.

Thanks!

1. https://lore.kernel.org/git/cover-v2-0.9-00000000000-20220831T205130Z-avarab@gmail.com/
2. https://lore.kernel.org/cocci/211116.86lf1op65q.gmgdl@evledraar.gmail.com/

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

end of thread, other threads:[~2022-09-01 18:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-01 15:00 [cocci] Optimizing *.cocci rules by concat'ing them Ævar Arnfjörð Bjarmason
2022-09-01 15:19 ` Julia Lawall
2022-09-01 18:12 ` [cocci] Checking consequences from concatenation of SmPL rules Markus Elfring

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.