A tool to manipulate python code at runtime for logging, profiling, debugging, etc.
Project description
pyliveupdate
PyLiveUpdate
is a runtime python bytecode 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
Key features
- Profile specific Python functions' (by function names or module names) call time.
- Add / remove profilings without restart programs.
- Support profiling multiple processes / threads.
- Show profiling results with call summary and flamegraphs.
- More features are under developing. (Let us know what features you want: https://github.com/devopspp/pyliveupdate/issues/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: https://github.com/devopspp/pyliveupdate/issues/2.
profile function call time
- Start pyliveupdate server
pylu-controller -l
- In your program (like examples/program1.py) main module add
from pyliveupdate import UpdateStub
from pyliveupdatescripts import FP
UpdateStub().start()
- Run your program (make sure in the correct directory)
cd examples
python program1.py
- Start profile a set of functions
FP.profile(['__main__.**', 'module1.**'])
or any functions
FP.profile('**')
- List applied profiling
FP.ls()
- Stop a profiling by its id without stopping your program
FP.revert(1)
- Process the logs to generate a summary and a flamegraph
pylu-processlogs -i /tmp/pyliveupdate.log
- 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
Profiling scope
- One specific function:
module1.class1.func1
- All functions in a class:
module1.class1.*
- 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: https://github.com/devopspp/pyliveupdate/issues/1
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for pyliveupdate-0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dad490f845596c6345bd951d506c338a24ccb8dde29d2cdff78db90cb7fa1dbf |
|
MD5 | 7ff8566d9f3be4f266de682743ec7368 |
|
BLAKE2b-256 | 3abaa20d79664f1e1b7b178d4e3ada78ecf8ed7b4a671165b9760242f8708482 |