cinder icon indicating copy to clipboard operation
cinder copied to clipboard

Add compilation statistics for static python

Open DinoV opened this issue 4 years ago • 4 comments
trafficstars

It'd be nice if we had some metrics around when/where we were emitting code in the static compiler which used static features. This could either be full statistics on opcodes used, or just individual stats on when we hit specific features. The compiler should expose some way to enable collecting this data and then we could log it out / dump it on compile.

DinoV avatar May 25 '21 18:05 DinoV

Do you know any existing such related metrics? Or can it be better to create a separate 'compiler step' just for testing on dev environment?

hexcubator avatar Jul 21 '22 15:07 hexcubator

HI @hexcubator , not sure I understand the question about separate compiler step -- what are you aiming to achieve?

We don't have metrics collection as described here yet; the only related thing we have is that the compiler does emit warnings when it falls back to dynamic behavior.

carljm avatar Jul 21 '22 18:07 carljm

I was aiming to create another check for the case when, as you mentioned, compiler does emit warnings when it falls back to dynamic behavior, do some kind of logging, in dev environment (preferably testing). We can, furthermore, create some common cases in JIT testing for static functions to create attributes like perf or time command on Linux.

hexcubator avatar Jul 22 '22 06:07 hexcubator

Currently the dynamic fallback warnings we have you can find by grepping Lib/compiler/static/ for perf_warning. These warnings are always collected during compilation, but not surfaced anywhere currently. If you dig a bit more into the internals, they should be available from the StrictSourceFileLoader as self.compiler.error_sink.warnings.

carljm avatar Jul 22 '22 22:07 carljm