How can I estimate the LOC of a linux component? In this case I would compare the LOC number that implement namespaces with the number of LOC which implement BPF.
-
1You'd have to figure out to which "component" different files belong. And that won't be enough, because many files are going to contain lines that pertain to namespaces or BPF without being only about one or the other. You can see an example of how I did this for BPF, by counting only entire files: pchaigno.github.io/bpf/2019/07/02/bpf-verifier-complexity.html.pchaigno– pchaigno2019-12-02 11:41:23 +00:00Commented Dec 2, 2019 at 11:41
-
Do you think is it right to assume that namespaces implementation requires a greater number of LOC compared with bpf?Maicake– Maicake2019-12-02 11:46:34 +00:00Commented Dec 2, 2019 at 11:46
-
I don't know...pchaigno– pchaigno2019-12-02 12:34:25 +00:00Commented Dec 2, 2019 at 12:34
1 Answer
Some components are well delineated; BPF is one of these, largely contained in kernel/bpf/. Others aren’t, such as namespaces.
The best way to determine where a feature is implemented is to look for its Kconfig option:
git grep CONFIG_BPF\\b
will find everything involved in BPF, and
git grep -E 'CONFIG_(UTS|IPC|USER|PID|NET)_NS\b'
will find everything involved in namespaces (see init/Kconfig).
At this point, you can try to figure out how much code these configuration options control. I would disable everything, then enable everything you need to get a specific feature, but not the feature itself, then pre-process all the code. Once that’s done, enable the feature, and pre-process all the code again, and measure the difference...