Profiling

Tools

We currently use cProfile for deterministic profiling and pyinstrument for statistical profiling.

We maintain a fork of pyinstrument where we stage changes that we want to merge upstream.

Proposed Data Format

 

type: trace
version: 1
root:
  - description: some_function_name
    self_time: 10.45  # number of seconds spent in this function that was not spent in functions called from within this function
    children:
      - description: inner_function  # This function was called by some_function_name()
        self_time: 1.456
      - description: another_function
        self_time: 0  # No appreciable time was spent in this function, all of the time was spent in the function it calls.
        children:
          - description: even_deeper
            self_time: 14.631
  - description: another_function
    self_time: 1.2  # This call to another_function does not result in a call to "even_deeper()" and does spend some time doing stuff. Note that appears separately in the data.