Skip to content

A runtime python code manipulation framework for profiling, debugging and bugfixing

License

Notifications You must be signed in to change notification settings

EvonX/pyliveupdate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

43c342e · Feb 26, 2020

History

44 Commits
Feb 24, 2020
Feb 24, 2020
Feb 24, 2020
Feb 4, 2020
Feb 4, 2020
Feb 6, 2020
Feb 26, 2020
Feb 24, 2020

Repository files navigation

pyliveupdate

PyLiveUpdate is a dynamic code manipulation (e.g. bytecode instrumentation) framework for profiling, debugging and bugfixing Python programs.

PyLiveUpdate allows developers to profile, diagnose and fix production issues for Python programs without restarting the programs.

Demo

asciicast

Key features

  • Profile specific Python functions' (by function names or module names) call time.
  • Add / remove profilings without restart programs.
  • Show profiling results with call summary and flamegraphs.
  • More features are under developing. (Let us know what features you want: devopspp#2)

Quick start

Compatibility

  • Supports Python 3.5+ on Linux.

Install

pip install pyliveupdate

or

git clone https://github.com/devopspp/pyliveupdate.git
pip install -e pyliveupdate

How to use

We currently implemented function profiling and are implementing more. Please feel free to let us know if you find other features useful: devopspp#2.

profile function call time

  1. Start pyliveupdate server
pylu-controller -l
  1. In your program (like examples/program1.py) main module add
from pyliveupdate import UpdateStub
from pyliveupdatescripts import FP
UpdateStub().start()
  1. Run your program (make sure in the correct directory)
cd examples
python program1.py
  1. Start profile a set of functions
FP.profile(['__main__.**', 'module1.**'])

or any functions

FP.profile('**')
  1. List applied profiling
FP.ls()
  1. Stop a profiling by its id without stopping your program
FP.revert(1)
  1. Process the logs to generate a summary and a flamegraph
pylu-processlogs -i /tmp/pyliveupdate.log
  1. View the generated call summary and flamegraph

Function call summary

The following summary gives in process 4510 thread 5, views.results was called 10 times and each time takes 139 ms, views.results called manager.all for 20 times.

4510-Thread-5
function  hit  time/hit (ms)
views.results 10  138.562
  -manager.all 20  14.212
    -__init__.__hash__ 10  0.035
    -manager.get_queryset 20  0.922
      -query.__init__ 20  0.616
        -query.__init__ 20  0.071

Flamegraph

alt text

Profiling scope

  1. One specific function: module1.class1.func1
  2. All functions in a class: module1.class1.*
  3. All functions in a module: module1.**

* means one-level nesting, ** means any level of nesting.

Known Users

Welcome to register your company/organization name here: devopspp#1

About

A runtime python code manipulation framework for profiling, debugging and bugfixing

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 81.8%
  • Perl 18.1%
  • Makefile 0.1%