Open geo2a opened 5 months ago
I would start very coarse grained, and only make it more fine-grained as we discover things. I would start with:
Then, whichever of those cost-centers is the biggest, break down into smaller cost-centers.
I guess the granularity can (or should) be tunable in the tool which reads and processes the logs, rather than having to re-run the proofs. So that's good because you can have very fast iteration on looking at cost-centers even for a long-running proof (if we store the log file).
Also, maybe visualizing the cost-centers and transit between them is useful. So building a graph where each type of log event we care about is a node, and edges between nodes are weighted with how much cumulative time is spent on that edge. That can give us an overall idea of how control flow is broken down in a more fine-grained manner. @jberthold made some diagrams like that for the old backend a long time ago.
Also, maybe visualizing the cost-centers and transit between them is useful. So building a graph where each type of log event we care about is a node, and edges between nodes are weighted with how much cumulative time is spent on that edge. That can give us an overall idea of how control flow is broken down in a more fine-grained manner. @jberthold made some diagrams like that for the old backend a long time ago.
The code to process the event logs has moved to https://github.com/runtimeverification/kore-prof/tree/master/src/TSM (currently unmaintained). The legacy kore
rewrite engine had (and still has) calls to insert "markers" into the event log, see here for an example (search for traceMarkerIO
used in marker
functions).
Only the rewrite rule application step instrumentation was merged to master back then.
I found an old file showing such a graph for the rule application during a test (evm-semantics, IIRC):
Motivation
When we try to understand why proofs are slow, we only have either very coarse-grained or very find-grained timing data. The coarse-grained data is either wall-clock time of running
kontrol
and other tools, or, at the level ofkore-rpc-booster
, the--log-stats
option which times the requests. The fine-grained tool is the GHC profiler, which gives us Haskell-level cost-centres.To better inform our decisions on what to work on to improve performance, we need something that sits in between.
Use cases
booster
aborts on rewrite rules (falling back tokore-rpc
)execute
andsimplify
requests (internal and external)Functionality
We would like to have a proof-level profiling tool that would allow us to find out, for both Booster and Kore:
Additionally, for Booster we would like to know:
Data source
We have implemented the contextual JSON logging, which, in conjunction with timestamps, should give us all the information we need. We may need to disable the buffering of the timestamps in
fast-logger
or, of that is not possible, figure out another to provide timestamps.Tool workflow and design
The tool's input will be the JSON log file, with every line being a json object. We should design the tool to support streaming the JSONs from the file so that we do not load it all into memory.
The log file will be generated by running the server with context logging enabled. This can be either done directly by the downstream tooling, i.e.
kontrol prove --profile
or by a script that consumes bug reports and runs the server with logging enabled.The output of the tool will likely be a Markdown/HTML document.