I am working on the profiling of postgresql
by llvm-cov
, but I find sometimes llvm-cov
will emit a too-large lcov file(~5GB) from a relatively smaller profdata(~100KB).
I tried to figure it out, but I got no ideas about what happened to the lcov file. And I didn't know why there are a lot of redundant lines, because these lines are not apparent in the source files.
I tried to export the lcov file as usual, but the lcov file was very large(~5GB).
$ llvm-cov export -format=lcov ../src/backend/postgres -instr-profile=$(pwd)/test.profdata > test.lcov
$ ll -h test.lcov
-rw-r--r-- 1 root root 5.3G Nov 6 18:35 test.lcov
I tried a lot of options to reduce the un-wanted lines (which is not apparent in the source file directly, but some definitions in the header. I don't want to see them in the lcov file more than once),including skip-functions
, but none of the options worked.
-rw-r--r-- 1 root root 50M Nov 6 18:12 test.show
-rw-r--r-- 1 root root 5.2M Nov 6 18:46 test.skip-functions.lcov
-rw-r--r-- 1 root root 5.3G Nov 6 18:35 test.sparse.lcov
There are 1060 files in lcov of postgres (counted by SF
in test.lcov). This is the first file's information.
SF:/postgresql-12.14/src/backend/access/brin/brin.c
FN:86,brinhandler
FN:148,brininsert
FN:340,brinbeginscan
FN:369,bringetbitmap
FN:564,brinrescan
FN:583,brinendscan
FN:663,brinbuild
FN:747,brinbuildempty
FN:778,brinbulkdelete
FN:792,brinvacuumcleanup
FN:822,brinoptions
FN:854,brin_summarize_new_values
FN:869,brin_summarize_range
FN:976,brin_desummarize_range
FN:1060,brin_build_desc
FN:1115,brin_free_desc
FN:1127,brinGetStats
FN:132,brin.c:MemoryContextSwitchTo # line 19
FN:1522,brin.c:table_index_build_scan
FN:605,brin.c:brinbuildCallback
FN:1149,brin.c:initialize_brin_buildstate
FN:1173,brin.c:terminate_brin_buildstate
FN:1346,brin.c:brinsummarize
FN:1219,brin.c:summarize_range
FN:1558,brin.c:table_index_build_range_scan
FN:1462,brin.c:union_tuples
FN:1442,brin.c:form_and_insert_tuple
FN:1504,brin.c:brin_vacuum_scan
FN:669,brin.c:DatumGetFloat4
FN:693,brin.c:Float4GetDatum
FN:717,brin.c:DatumGetFloat8
FN:742,brin.c:Float8GetDatum
FN:78,brin.c:list_head
FN:84,brin.c:list_tail
FN:90,brin.c:list_length
...
DA:1528,0
DA:1529,0
DA:1530,0
DA:1531,0
DA:1532,0
DA:1533,0
LF:1230
LH:0
end_of_record
The line informations are correctly matched(lines in lcov starting with DA
); And some function lines are correct, especially the first 18 lines. But lines after that started to get strange, for 1. the number is wrong if it is line number of source code; 2. the file names seem to jump out of logic; 3. the function name is not appear in that number of line in source code.
Take line 19(FN:132,brin.c:MemoryContextSwitchTo, I added a comment in the lcov file above) for example, the lcov shows FN:132
in brin.c
part, but it is
* A tuple in the heap is being inserted. To keep a brin index up to date,
in brin.c, which is actually a comment.
I will appreciate it if someone could tell me what dose this mismatched lines mean, and why could they be emitted by llvm-cov export
.
Really thank you!:))