sumerc / yappi

Yet Another Python Profiler, but this time multithreading, asyncio and gevent aware.
MIT License
1.44k stars 72 forks source link

Callgrind format shows lot of unknown function #95

Closed saurabhkgp21 closed 8 months ago

saurabhkgp21 commented 2 years ago

When saving the yappi profile output as callgrind format, qcachegrind shows a major chunk of time spent in unknown function with output on a console similar to this

Loading "./file_name.profile" : 3808 :  "Undefined compressed file index 1887"
Loading "./file_name.profile" : 3808 :  "Invalid specification of called file, setting to unknown"
Loading "./file_name.profile" : 3809 :  "Undefined compressed function index 1887"
Loading "./file_name.profile" : 3809 :  "Invalid called function, setting to unknown"

In _save_as_CALLGRIND function, while adding the function definitions we only iterate over function stats

for func_stat in self:
  file_ids += ['fl=(%d) %s' % (func_stat.index, func_stat.module)]
  func_ids += [
      'fn=(%d) %s %s:%s' % (
          func_stat.index, func_stat.name, func_stat.module,
          func_stat.lineno
      )
  ]

Function/File definitions of some child functions were not specified in the callgrind format which was causing this issue.