Add overlap functionality to llvm-profdata tool to compute the similarity between two profile files.
Details
Diff Detail
Event Timeline
llvm/docs/CommandGuide/llvm-profdata.rst | ||
---|---|---|
240 | match underscore length with word. | |
250 | show --> overlap | |
253 | as follows | |
258 | add space between ')' and 'and' | |
259 | what does 'unique' mean here? | |
270 | This definition of 'overlap' captures branch probability well (relatvie), but loses the information on absolute count. There should be an option to measure that. |
llvm/docs/CommandGuide/llvm-profdata.rst | ||
---|---|---|
259 | I changed to "unmatched counters (or counters only existing in) " | |
270 | You are right that it does not computer the absolute counter difference. The overlap is actually the overlap of distribution of the counts. The summary of the overlap does print out the sum of the counts for both profiles. But the absolute counter difference is not the main purpose. |
llvm/docs/CommandGuide/llvm-profdata.rst | ||
---|---|---|
268 | not --> no | |
286 | -o=output or -o output | |
llvm/lib/ProfileData/InstrProf.cpp | ||
1210 | For function level dump, the # of function is redundant -- perhaps change it to # of counters The overall dump format looks better with this:
| |
1211 | The header and content does not match in fields. | |
llvm/lib/ProfileData/InstrProfWriter.cpp | ||
190 | Why is this a writer method? | |
llvm/tools/llvm-profdata/llvm-profdata.cpp | ||
223 | The title print including the summary can be pushed into FuncOverlap::dump() method | |
228 | The title can be pushed into FunctionOverlap::dump() method. |
llvm/docs/CommandGuide/llvm-profdata.rst | ||
---|---|---|
286 | it does take -output. | |
llvm/lib/ProfileData/InstrProf.cpp | ||
1210 | I will change to this format. add number of counts to function level is a good idea. | |
1211 | why this does not match? | |
llvm/lib/ProfileData/InstrProfWriter.cpp | ||
190 | because this reuses the merge framework (load the base profile to write context) and load the second one to do the overlap calculation. | |
llvm/tools/llvm-profdata/llvm-profdata.cpp | ||
223 | This would require to put a flag in the structure to distinguish whether this is function level or program level. It can be done. | |
228 | This would require add both profile file name to the structure. |
llvm/include/llvm/ProfileData/InstrProf.h | ||
---|---|---|
594 | How to tell if count or percentage is stored here? | |
597 | The name EdgeCount is misleading -- it sounds like number of 'edges' in CFG. Perhaps just 'TotalCount' or 'CountSum' | |
612 | BaseSum-->Base | |
614 | TestSum --> Test | |
llvm/lib/ProfileData/InstrProf.cpp | ||
482 | This is not 'getCountSums' -- but 'accumuateCounts' -- perhaps rename it. | |
511 | The loop nest can be merged into one single loop: while (i != ie && j != je) { if (i->v == j->v) { //match: ... i++; j++; } else if (i->v > j->v) { j++; // handle mismatch case -- as one value appears in only one record (assuming count == 0) ... } else { i++; // handle mismatch } } // handle the rest of the mismatched cases. } | |
553 | already be computed and is nonzero | |
560 | Perhaps just check the function hash? | |
596 | += or just = ? | |
llvm/tools/llvm-profdata/llvm-profdata.cpp | ||
212 | -> silently I don't see a return here. |
llvm/include/llvm/ProfileData/InstrProf.h | ||
---|---|---|
594 | The caller should keep track of this. This data structure does not know -- it just a floating points. | |
llvm/lib/ProfileData/InstrProf.cpp | ||
511 | Yes. The version I used is a copy from merge function. | |
553 | Yes. it's true for call chains in this patch. | |
560 | FuncHash already being checked (In Reader). This is just to handle the cases that escapes the hash check. | |
596 | they are the same. the incoming value should be 0 by the initializer. |
llvm/tools/llvm-profdata/llvm-profdata.cpp | ||
---|---|---|
212 | fixed |
Discussed offline with David. We changed the output to a simpler: "Description: <Value>" format. This tool will mostly used in a script. Simpler format will make text grep cleaner.
llvm/lib/ProfileData/InstrProfWriter.cpp | ||
---|---|---|
219 | setting to zero so that the comparison always true in function InstrProfRecord::overlap() (so that we output function level information). |
Adjusted the output string with David's comments.
Also made the naming more uniformed for edge and value profiles.
match underscore length with word.