Chromiumの規模を確認する その4: 変更が多かった場所

# 目的
[前回](https://qiita.com/rairaii/items/cd355411da5f766926e5) は Chromium の M88 と M89 とでの変更量を確認した
今回は変更量が大きかった領域を確認する

# 結論
C, C++, Assembly, Java の４言語での差分

| 内容 | 結論 |
|:-:|:-:|
| レンダリングエンジン Blink の変更量 | 10万LOC (変更全体のほぼ 1/10) |
| JavaScriptエンジン v8 の変更量 | 4万LOC |
| 最も変更量が多かったコンポーネント | 27万LOC (Chrome) |


# src 以下のディレクトリ毎の変更量
C, C++, Assembly, Java の４言語に絞って確認する

```shell-session
$ touch /tmp/NULL
```

バージョンが変わって削除されたファイルやディレクトリの比較でエラーがでないようにダミーファイル (/tmp/NULL) を用意する

```shell-session
$ time \
for d in `for i in  chromium/src/* chromium2/src/* ; do basename $i; done | sort | uniq `; \
do \
    name=`basename $d`; \
    c1="chromium/src/$name"; \
    c2="chromium2/src/$name"; \
    if [ ! -e $c1 ] ; then \
        c1="/tmp/NULL";  \
        echo "[0] $c2" 1>&2; \
    elif [ ! -e $c2 ] ; then \
        c2="/tmp/NULL"; \
        echo "[+] $c1" 1>&2; \
    fi ; \
    ~/work/cloc-1.88/cloc --quiet --diff --timeout=60 --diff-timeout=60 --csv $c2 $c1 \
    | tail +3 | sed "s@^@$name,@"; \
done  \
| sed  1i"dir, Language, == files, != files, + files, - files, == blank, != blank, + blank, - blank, == comment, != comment, + comment, - comment, == code, != code, + code, - code"  \
> cloc_diff_M88_M89_src.csv 

3 errors:
Diff error, exceeded timeout:  chromium2/src/testing/buildbot/chromium.fyi.json v. chromium/src/testing/buildbot/chromium.fyi.json
Diff error, exceeded timeout:  chromium2/src/testing/buildbot/chromium.clang.json v. chromium/src/testing/buildbot/chromium.clang.json
Diff error, exceeded timeout:  chromium2/src/testing/buildbot/chromium.android.json v. chromium/src/testing/buildbot/chromium.android.json

1 error:
Diff error, exceeded timeout:  chromium2/src/third_party/blink/web_tests/external/WPT_BASE_MANIFEST_8.json v. chromium/src/third_party/blink/web_tests/external/WPT_BASE_MANIFEST_8.json

2 errors:
Diff error, exceeded timeout:  chromium2/src/tools/metrics/histograms/histograms_xml/obsolete_histograms.xml
Diff error, exceeded timeout:  chromium/src/tools/metrics/histograms/histograms_xml/obsolete_histograms.xml

real	41m3.007s
user	35m14.436s
sys	2m5.908s

```
削除・追加されたディレクトリはない
diff でタイムアウトしているファイルは大勢に影響なさそうなので無視して進める

C, C++, Assembly, Javaの４言語のみに絞って LOC を確認する
third_partyが40万LOCと飛び抜けて変更量が多い 

|	Directory	|	変更	|	追加	|	削除	|	合計|
|:-:|--:|--:|--:|--:|
|	third_party	|	36,815	|	110,806	|	259,397	|	407,018	|
|	chrome	|	34,405	|	144,731	|	95,094	|	274,230	|
|	components	|	15,346	|	61,823	|	25,718	|	102,887	|
|	content	|	8,778	|	24,457	|	16,319	|	49,554	|
|	ash	|	3,494	|	18,949	|	8,095	|	30,538	|
|	ui	|	3,944	|	12,472	|	4,868	|	21,284	|
|	chromeos	|	1,490	|	13,146	|	6,468	|	21,104	|
|	services	|	2,590	|	9,321	|	2,821	|	14,732	|
|	media	|	1,660	|	9,604	|	2,033	|	13,297	|
|	net	|	2,777	|	7,302	|	2,495	|	12,574	|
|	base	|	2,115	|	4,929	|	2,849	|	9,893	|
|	device	|	567	|	2,871	|	5,012	|	8,450	|
|	chromecast	|	573	|	5,661	|	1,955	|	8,189	|
|	extensions	|	1,913	|	1,771	|	2,004	|	5,688	|
|	android_webview	|	461	|	3,191	|	1,299	|	4,951	|
|	cc	|	1,113	|	2,670	|	719	|	4,502	|
|	weblayer	|	380	|	2,508	|	1,519	|	4,407	|
|	ios	|	231	|	1,970	|	1,510	|	3,711	|
|	sandbox	|	18	|	59	|	2,467	|	2,544	|
|	gpu	|	352	|	1,190	|	325	|	1,867	|
|	fuchsia	|	134	|	1,293	|	307	|	1,734	|
|	crypto	|	36	|	124	|	1,336	|	1,496	|
|	pdf	|	372	|	838	|	158	|	1,368	|
|	remoting	|	228	|	887	|	185	|	1,300	|
|	mojo	|	391	|	391	|	304	|	1,086	|
|	tools	|	103	|	596	|	139	|	838	|
|	skia	|	102	|	505	|	141	|	748	|
|	google_apis	|	233	|	357	|	113	|	703	|
|	storage	|	306	|	159	|	50	|	515	|
|	url	|	124	|	328	|	55	|	507	|
|	printing	|	116	|	366	|	19	|	501	|
|	headless	|	30	|	160	|	45	|	235	|
|	sql	|	4	|	126	|	5	|	135	|
|	gin	|	16	|	70	|	4	|	90	|
|	build	|	16	|	36	|	8	|	60	|
|	ipc	|	19	|	27	|	4	|	50	|
|	rlz	|	21	|	7	|	0	|	28	|
|	ppapi	|	7	|	9	|	2	|	18	|
|	apps	|	2	|	7	|	7	|	16	|
|	testing	|	6	|	0	|	3	|	9	|
|	native_client_sdk	|	0	|	0	|	0	|	0	|
|	jingle	|	0	|	0	|	0	|	0	|
|	dbus	|	0	|	0	|	0	|	0	|
|	courgette	|	0	|	0	|	0	|	0	|
|	codelabs	|	0	|	0	|	0	|	0	|
|	cloud_print	|	0	|	0	|	0	|	0	|
|	buildtools	|	0	|	0	|	0	|	0	|
|	総計	|	121,288	|	445,717	|	445,852	|	1,012,857	|

# third_party の変更を確認する

```shell-session
$ time \
for d in `for i in  chromium/src/third_party/* chromium2/src/third_party/* ; do basename $i; done | sort | uniq `; \
do \
    name=`basename $d`; \
    c1="chromium/src/third_party/$name"; \
    c2="chromium2/src/third_party/$name"; \
    if [ ! -e $c1 ] ; then \
        c1="/tmp/NULL";  \
        echo "[-] $c2" 1>&2; \
    elif [ ! -e $c2 ] ; then \
        c2="/tmp/NULL"; \
        echo "[+] $c1" 1>&2; \
    fi ; \
    ~/work/cloc-1.88/cloc --quiet --diff --timeout=60 --diff-timeout=60 --csv $c2 $c1 \
    | tail +3 | sed "s@^@$name,@"; \
done  \
| sed  1i"dir, Language, == files, != files, + files, - files, == blank, != blank, + blank, - blank, == comment, != comment, + comment, - comment, == code, != code, + code, - code"  \
> cloc_diff_M88_M89_src_third_party.csv 

[-] chromium2/src/third_party/adobe

1 error:
Diff error, exceeded timeout:  chromium2/src/third_party/blink/web_tests/external/WPT_BASE_MANIFEST_8.json v. chromium/src/third_party/blink/web_tests/external/WPT_BASE_MANIFEST_8.json
[+] chromium/src/third_party/eigen3
[+] chromium/src/third_party/emoji-metadata
[+] chromium/src/third_party/farmhash
[+] chromium/src/third_party/fft2d
[+] chromium/src/third_party/fp16
[+] chromium/src/third_party/gemmlowp
[-] chromium2/src/third_party/glslang
[-] chromium2/src/third_party/guava
[+] chromium/src/third_party/neon_2_sse
[+] chromium/src/third_party/ruy
[-] chromium2/src/third_party/shaka-player
[-] chromium2/src/third_party/spirv-cross
[-] chromium2/src/third_party/spirv-headers
[-] chromium2/src/third_party/SPIRV-Tools
[+] chromium/src/third_party/tflite
[-] chromium2/src/third_party/vulkan_headers

real	13m11.152s
user	11m53.177s
sys	0m36.285s
```

|削除されたディレクトリ |
|:--|
|src/third_party/adobe |
|src/third_party/glslang |
|src/third_party/guava |
|src/third_party/shaka-player |
|src/third_party/spirv-cross |
|src/third_party/spirv-headers |
|src/third_party/SPIRV-Tools |
|src/third_party/vulkan_headers |

|追加されたディレクトリ |
|:--|
|src/third_party/eigen3 |
|src/third_party/emoji-metadata |
|src/third_party/farmhash |
|src/third_party/fft2d |
|src/third_party/fp16 |
|src/third_party/gemmlowp |
| src/third_party/neon_2_sse |
|src/third_party/ruy |
|src/third_party/tflite |

エラーは無視しても問題ないのでそのまま進める

## third_party ディレクトリの変更量
third_party ディレクトリ内で変更量の大きい順に確認する

- Chromiumのレンダリングエンジンである Blink が最も変更量が多く約10万LOC
- Protocol Buffers や AV1 のデコーダが大きな変更


Directory	|	変更	|	追加	|	削除	|	合計	|
|:-:|--:|--:|--:|--:|
|	blink	|	15,610	|	45,718	|	39,034	|	100,362	|
|	protobuf	|	14,368	|	35,395	|	49,516	|	99,279	|
|	vulkan_headers	|	0	|	0	|	82,183	|	82,183	|
|	libaom	|	162	|	0	|	77,587	|	77,749	|
|	win_build_output	|	424	|	10,207	|	8,510	|	19,141	|
|	boringssl	|	4,071	|	8,899	|	724	|	13,694	|
|	abseil-cpp	|	419	|	3,725	|	748	|	4,892	|
|	brotli	|	1,497	|	2,038	|	804	|	4,339	|
|	fft2d	|	0	|	3,697	|	0	|	3,697	|
|	crashpad	|	198	|	433	|	237	|	868	|
|	liburlpattern	|	41	|	385	|	4	|	430	|
|	grpc	|	0	|	243	|	0	|	243	|
|	mozilla	|	0	|	0	|	38	|	38	|
|	inspector_protocol	|	3	|	25	|	0	|	28	|
|	android_deps	|	0	|	19	|	4	|	23	|
|	opus	|	0	|	20	|	0	|	20	|
|	zlib	|	11	|	0	|	1	|	12	|
|	leveldatabase	|	2	|	0	|	4	|	6	|
|	gvr-android-sdk	|	5	|	0	|	0	|	5	|
|	libvpx	|	3	|	0	|	0	|	3	|
|	adobe	|	0	|	0	|	3	|	3	|
|	libva_protected_content	|	0	|	2	|	0	|	2	|
|	r8	|	1	|	0	|	0	|	1	|
|	zxcvbn-cpp	|	0	|	0	|	0	|	0	|
|	...	|	...	|	...	|	...	|	...	|
|	afl	|	0	|	0	|	0	|	0	|
|	総計	|	36,815	|	110,806	|	259,397	|	407,018	|

# v8の差分

下記のv8の差分を確認する
- 88.0.4324.91
- 89.0.4388.4

| Chromium のバージョン | v8 のバージョン |
|:-:|:-:|
| 88.0.4324.91  | cbcbe9243488ceffd693a94a335bfd4d09b1e9ca  |
| 89.0.4388.4  | 8b42c4e7175e5d28c57d72dade99c52a144bec1f  |

```shell-session
$ cd chromium2/src/
$ git status
HEAD detached at 88.0.4324.91
nothing to commit, working tree clean
$ cat DEPS | grep v8
  'v8_revision': 'cbcbe9243488ceffd693a94a335bfd4d09b1e9ca',
              'version': 'y8fIfH8Leo2cPm7iGCYnBxZpwOlgLv8rm2mlcmJlvGsC',
  'src/v8':
    Var('chromium_git') + '/v8/v8.git' + '@' +  Var('v8_revision'),
  'v8',
                '--bucket', 'v8-wasm-fuzzer',
                '-s', 'src/v8/test/fuzzer/wasm_corpus.tar.gz.sha1',
```



```shell-session
$  time ~/work/cloc-1.88/cloc --quiet --csv --git-diff-all --timeout=60 --diff-timeout=60 cbcbe9243488ceffd693a94a335bfd4d09b1e9ca 8b42c4e7175e5d28c57d72dade99c52a144bec1f > ../cloc_diff_M88_M89_v8.csv

real	2m44.866s
user	2m39.741s
sys	0m5.018s

```

|	Language	|	変更	|	追加	|	削除	|	合計	|
|:-:|--:|--:|--:|--:|
|	C++	|	10,227	|	15,597	|	8,281	|	34,105	|
|	JavaScript	|	1,269	|	6,050	|	3,306	|	10,625	|
|	C/C++ Header	|	2,368	|	5,658	|	1,804	|	9,830	|
|	HTML	|	62	|	741	|	565	|	1,368	|
|	Python	|	429	|	503	|	144	|	1,076	|
|	Lua	|	0	|	0	|	407	|	407	|
|	JSON	|	97	|	9	|	158	|	264	|
|	Bourne Shell	|	33	|	26	|	32	|	91	|
|	CSS	|	7	|	81	|	0	|	88	|
|	XML	|	0	|	44	|	0	|	44	|
|	YAML	|	0	|	8	|	0	|	8	|
|	Markdown	|	3	|	3	|	0	|	6	|
|	DOS Batch	|	1	|	0	|	0	|	1	|
|	Windows Module Definition	|	0	|	0	|	0	|	0	|
|	WebAssembly	|	0	|	0	|	0	|	0	|
|	vim script	|	0	|	0	|	0	|	0	|
|	TypeScript	|	0	|	0	|	0	|	0	|
|	Scheme	|	0	|	0	|	0	|	0	|
|	R	|	0	|	0	|	0	|	0	|
|	make	|	0	|	0	|	0	|	0	|
|	C	|	0	|	0	|	0	|	0	|
|	Bourne Again Shell	|	0	|	0	|	0	|	0	|
|	Assembly	|	0	|	0	|	0	|	0	|
|	総計	|	14,496	|	28,720	|	14,697	|	57,913	|

|	Language	|	変更	|	追加	|	削除	|	合計	|
|:-:|--:|--:|--:|--:|
|	C++	|	10,227	|	15,597	|	8,281	|	34,105	|
|	C/C++ Header	|	2368	|	5658	|	1804	|	9830	|
|	C	|	0	|	0	|	0	|	0	|
|	Assembly	|	0	|	0	|	0	|	0	|
|	合計	|	12,595	|	21,255	|	10,085	|	43,935	|