facebookincubator / cinder

Cinder is Meta's internal performance-oriented production version of CPython.
https://trycinder.com
Other
3.49k stars 121 forks source link

Add compilation statistics for static python #17

Open DinoV opened 3 years ago

DinoV commented 3 years ago

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.

hexcubator commented 2 years ago

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?

carljm commented 2 years ago

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.

hexcubator commented 2 years ago

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.

carljm commented 2 years ago

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.