8

I want to profile my Python program to understand why it is so slow. I decided to use Yappi - because my program is multithreaded - and to diplay the results with KCacheGrind. Here is how I do it:

# Profile of the update method
def profile_update(table, start, end):
    print("Profiling update() on the %s table..." % (table))
    yappi.start(builtins=True)
    app.update(...)
    stats = yappi.get_func_stats()
    output_name = "profiler_%s.out." % (table) + datetime.now().isoformat()
    stats.save("profilers_outputs/" + output_name, type='callgrind')
    yappi.stop()
    yappi.clear_stats()
    print('\n\n\n')

The method update is used to fetch data from a database with a time range between start and end.

The output file is correctly created but when I launch KCacheGrind it prints a lot of errors like this:

kcachegrind(35484): Loading "profilers_outputs/profiler_benchmark.out.2019-06-26T17:21:41.147461" : 17529 :  "Undefined compressed function index 586"
kcachegrind(35484): Loading "profilers_outputs/profiler_benchmark.out.2019-06-26T17:21:41.147461" : 17529 :  "Invalid called function, setting to unknown"

I end up with this call graph where all the non recognized functions are aggregated as one, making it messy and completely irrelevant. Does anyone know why it is happening ?

Gaëtan
  • 779
  • 1
  • 8
  • 26

0 Answers0