Skip to content

Python: more call graph tracing#3953

Merged
codeql-ci merged 70 commits intogithub:mainfrom
RasmusWL:python-more-call-graph-tracing
Sep 7, 2020
Merged

Python: more call graph tracing#3953
codeql-ci merged 70 commits intogithub:mainfrom
RasmusWL:python-more-call-graph-tracing

Conversation

@RasmusWL
Copy link
Member

@RasmusWL RasmusWL commented Jul 16, 2020

This PR expands on the capabilities of the call graph tracer. It's a pretty big one, so it's hard to summarize concisely what has happened... a LOT. Almost everything changed 😄

Sadly, I didn't find time to write tests, or invest much in writing documentation for the Python code. I prioritized getting this to a point where it can be used for evaluating quality of the new call-graph resolution.

Overall it's in a state where it can run on the test suite of real projects, but not through tox, so some manual adaptation of commands is required for settings up a new projects (although it's fairly easy) -- see ./projects.json and the README for details.

RasmusWL added 23 commits July 17, 2020 13:49
And make code pass flake8 tests
As recommended in https://blog.ionelmc.ro/2014/05/25/python-packaging/ and
following pattern of black and pytest
So we can differentiate multiple calls in one line.
There are currently 16 InvalidRecordedCall
Reduced number of InvalidRecordedCall from 16 to 2. This is the calls

```
one(); one()
```

since they are not distinguishable from the expression.
Such as

```
one(); one()
```

Now there are no InvalidRecordedCall in the current examples.
As would normally be invoked by `python -m <module-name>` now works with
`cg-trace --module <module-name>`.

This is useful for tracing invocations of `pytest`.
otherwise, with-exit would end the tracer without producing any output :|
Which relies on LOAD_CONST and MAKE_FUNCTION
RasmusWL added 21 commits July 23, 2020 14:01
Also exposed that the better_compare_for_dataclass was exposed to bad loop
variable capture :|
Currently not supported in the QL code, so no reason to pay performance to
record them right now :P
Improves runtime of tracing youtube-dl from 296.19 seconds to 224.50 seconds.

Better, but still not that amazing :|
Seems like a 2x performance overall

wcwidth:
  - DEBUG=True 5.78 seconds
  - DEBUG=False 2.70 seconds

youtube-dl
  - DEBUG=True 238.90 seconds
  - DEBUG=False 120.70 seconds
Some code I had lying around, just hadn't comitted.

Not that useful since most of these have been disabled in 55404ae for now.
@RasmusWL RasmusWL marked this pull request as ready for review July 24, 2020 18:44
@RasmusWL RasmusWL requested a review from a team as a code owner July 24, 2020 18:44
@adityasharad adityasharad changed the base branch from master to main August 14, 2020 18:33
Copy link
Contributor

@tausbn tausbn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few comments and suggestions (mostly concerning documentation), and questions, but otherwise this looks good to me.

RasmusWL and others added 2 commits September 7, 2020 14:59
Co-authored-by: Taus <tausbn@github.com>
Was introduced in 5d031d7 when I actually fixed
the loop variable capture problem.
@codeql-ci codeql-ci merged commit 22b3b0a into github:main Sep 7, 2020
@RasmusWL RasmusWL deleted the python-more-call-graph-tracing branch September 7, 2020 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants