This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author pdmccormick
Recipients Francis Deslauriers, jcea, lukasz.langa, pdmccormick
Date 2017-02-19.05:09:47
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1487480990.1.0.992247191356.issue28909@psf.upfronthosting.co.za>
In-reply-to
Content
Fork at <https://github.com/pdmccormick/cpython/tree/bpo-28909-adding-lttng-ust> with Francis' original patch, plus a revert for the DTrace provider name change.

Here are instructions I used to try this out:

## LTTng installation

Full installation instructions for LTTng are available at <https://lttng.org/download/>. On Ubuntu 19.04 you can currently install LTTng v2.7 from the `universe` repository if it is enabled:

```shell
$ apt-get install lttng-tools lttng-modules-dkms liblttng-ust-dev babeltrace
```

## Building

Clone/fetch/checkout from <https://github.com/pdmccormick/cpython/tree/bpo-28909-adding-lttng-ust> and run:

```shell
$ ./configure --with-lttngust
$ make
```

## Tracing a session

LTTng operates around the concept of tracing selected userspace & kernelspace events of interest within the context of a session, so let's start one and run the instrumented interpreter to see what happens:

```shell
$ lttng create 'pysession'
$ lttng enable-event --userspace 'cpython:*'
$ lttng start
$ ./python -m this
$ lttng stop
$ lttng view | wc -l
48257
$ lttng view
[23:50:04.493873655] (+?.?????????) keflavik cpython:gc__start: { cpu_id = 1 }, { generation = 0 }
[23:50:04.493910472] (+0.000036817) keflavik cpython:gc__done: { cpu_id = 1 }, { collected = 0 }
[23:50:04.494281326] (+0.000370854) keflavik cpython:gc__start: { cpu_id = 1 }, { generation = 0 }
[23:50:04.494305307] (+0.000023981) keflavik cpython:gc__done: { cpu_id = 1 }, { collected = 0 }
[23:50:04.495031049] (+0.000725742) keflavik cpython:gc__start: { cpu_id = 1 }, { generation = 0 }
[23:50:04.495074272] (+0.000043223) keflavik cpython:gc__done: { cpu_id = 1 }, { collected = 0 }
[23:50:04.495403759] (+0.000329487) keflavik cpython:function__entry: { cpu_id = 1 }, { co_filename = "<frozen importlib._bootstrap>", co_name = "<module>", line_no = 8 }
[23:50:04.495405056] (+0.000001297) keflavik cpython:line: { cpu_id = 1 }, { co_filename = "<frozen importlib._bootstrap>", co_name = "<module>", line_no = 8 }
[23:50:04.495406486] (+0.000001430) keflavik cpython:line: { cpu_id = 1 }, { co_filename = "<frozen importlib._bootstrap>", co_name = "<module>", line_no = 25 }
[23:50:04.495407149] (+0.000000663) keflavik cpython:line: { cpu_id = 1 }, { co_filename = "<frozen importlib._bootstrap>", co_name = "<module>", line_no = 27 }
[23:50:04.495408921] (+0.000001772) keflavik cpython:line: { cpu_id = 1 }, { co_filename = "<frozen importlib._bootstrap>", co_name = "<module>", line_no = 35 }
[23:50:04.495409618] (+0.000000697) keflavik cpython:line: { cpu_id = 1 }, { co_filename = "<frozen importlib._bootstrap>", co_name = "<module>", line_no = 42 }
[23:50:04.495410775] (+0.000001157) keflavik cpython:line: { cpu_id = 1 }, { co_filename = "<frozen importlib._bootstrap>", co_name = "<module>", line_no = 44 }
[23:50:04.495412006] (+0.000001231) keflavik cpython:line: { cpu_id = 1 }, { co_filename = "<frozen importlib._bootstrap>", co_name = "<module>", line_no = 47 }
[23:50:04.495421990] (+0.000009984) keflavik cpython:function__entry: { cpu_id = 1 }, { co_filename = "<frozen importlib._bootstrap>", co_name = "_DeadlockError", line_no = 47 }
[23:50:04.495422496] (+0.000000506) keflavik cpython:line: { cpu_id = 1 }, { co_filename = "<frozen importlib._bootstrap>", co_name = "_DeadlockError", line_no = 47 }
[23:50:04.495423317] (+0.000000821) keflavik cpython:line: { cpu_id = 1 }, { co_filename = "<frozen importlib._bootstrap>", co_name = "_DeadlockError", line_no = 48 }
[23:50:04.495424559] (+0.000001242) keflavik cpython:function__return: { cpu_id = 1 }, { co_filename = "<frozen importlib._bootstrap>", co_name = "_DeadlockError", line_no = 48 }
[23:50:04.495468551] (+0.000043992) keflavik cpython:line: { cpu_id = 1 }, { co_filename = "<frozen importlib._bootstrap>", co_name = "<module>", line_no = 51 }
[23:50:04.495470096] (+0.000001545) keflavik cpython:function__entry: { cpu_id = 1 }, { co_filename = "<frozen importlib._bootstrap>", co_name = "_ModuleLock", line_no = 51 }
[23:50:04.495470570] (+0.000000474) keflavik cpython:line: { cpu_id = 1 }, { co_filename = "<frozen importlib._bootstrap>", co_name = "_ModuleLock", line_no = 51 }
[23:50:04.495471249] (+0.000000679) keflavik cpython:line: { cpu_id = 1 }, { co_filename = "<frozen importlib._bootstrap>", co_name = "_ModuleLock", line_no = 55 }
[23:50:04.495471746] (+0.000000497) keflavik cpython:line: { cpu_id = 1 }, { co_filename = "<frozen importlib._bootstrap>", co_name = "_ModuleLock", line_no = 57 }
...
```

The raw trace files will be written under `~/lttng-traces/pysession-$TIMESTAMP`. To clean them up afterwards, you can run:

```shell
$ lttng destroy
```

## GitHub

I would be happy to re-post this to GitHub issues if so desired.
History
Date User Action Args
2017-02-19 05:09:50pdmccormicksetrecipients: + pdmccormick, jcea, lukasz.langa, Francis Deslauriers
2017-02-19 05:09:50pdmccormicksetmessageid: <1487480990.1.0.992247191356.issue28909@psf.upfronthosting.co.za>
2017-02-19 05:09:50pdmccormicklinkissue28909 messages
2017-02-19 05:09:47pdmccormickcreate