llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

Negative numbers reported with: opt -time-passes -track-memory

Open anmparal opened this issue 9 years ago • 7 comments

Bugzilla Link 34535
Version trunk
OS All
CC @anmparal,@MatzeB

Extended Description

Why are there negative numbers in the Mem column?

opt -time-passes -track-memory ./p0.bc -O3 -o p0.O3.bc

===-------------------------------------------------------------------------=== ... Pass execution timing report ... ===-------------------------------------------------------------------------===

…

---User Time--- --User+System-- ---Wall Time--- ---Mem--- --- Name --- 0.0010 ( 33.3%) 0.0010 ( 33.3%) 0.0012 ( 41.2%) 324576 Simplify the CFG … 0.0000 ( 0.0%) 0.0000 ( 0.0%) 0.0000 ( 0.4%) -7184 Scalar Evolution Analysis …

Ref: http://lists.llvm.org/pipermail/llvm-dev/2017-September/117069.html

anmparal avatar Sep 08 '17 23:09 anmparal

When a pass removes more datastructures (instructions, metadata, ...) than it creates I can see this happening. The number is the difference of memory used before and after running a pass.

Then, I'd say that keeping the negative numbers is actually a good thing because it helps in understanding pass behaviour. If the documentation:

-track-memory - Enable -time-passes memory tracking (this may be slow)

is updated to reflect the same; it would not be confusing anymore.

anmparal avatar Sep 09 '17 00:09 anmparal

I'd leave the behavior as is.

(If anything I would remove the whole option, and recomment people to rather use something like valgrind/massif, instruments etc. to capture actual peak memory usage. I don't see the use in before/after pass comparisons, esp. with analysis passes sometimes staying alive for a longer timer).

Yes, I tend to agree. FWIW, the same issue happens with -time-passes, LVI returns pretty much no time but Jump Threading and VRP account for all the time spent in it, so the numbers are already somehow wrong. I'd claim that with the approximate measurements time-passes is still useful no matter what although, as you say, it's hard to imagine why you don't want to use valgrind (or something similar) for memory measurements.

llvmbot avatar Sep 09 '17 00:09 llvmbot

I'd leave the behavior as is.

(If anything I would remove the whole option, and recomment people to rather use something like valgrind/massif, instruments etc. to capture actual peak memory usage. I don't see the use in before/after pass comparisons, esp. with analysis passes sometimes staying alive for a longer timer).

MatzeB avatar Sep 09 '17 00:09 MatzeB

When a pass removes more datastructures (instructions, metadata, ...) than it creates I can see this happening. The number is the difference of memory used before and after running a pass.

Yes, that's what happening (just debugged). I think it's a little weird but presumably we should live with it? The alternative would be that of just report zero in ca se the number is negative? (I guess that may be less confusing, but also less useful).

llvmbot avatar Sep 09 '17 00:09 llvmbot

When a pass removes more datastructures (instructions, metadata, ...) than it creates I can see this happening. The number is the difference of memory used before and after running a pass.

MatzeB avatar Sep 09 '17 00:09 MatzeB

Bitcode file to reproduce the problem. Thank you, Davide.

anmparal avatar Sep 09 '17 00:09 anmparal

Please provide a bitcode file to reproduce this.

llvmbot avatar Sep 08 '17 23:09 llvmbot