Python: more call graph tracing#3953
Merged
codeql-ci merged 70 commits intogithub:mainfrom Sep 7, 2020
Merged
Conversation
Allows comparing output of one run with another
makes it easy to switch out XML library.
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
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
turned out to be useful after all :P
Some code I had lying around, just hadn't comitted. Not that useful since most of these have been disabled in 55404ae for now.
Not 100% perfect, but better
tausbn
requested changes
Sep 1, 2020
Contributor
tausbn
left a comment
There was a problem hiding this comment.
A few comments and suggestions (mostly concerning documentation), and questions, but otherwise this looks good to me.
python/tools/recorded-call-graph-metrics/ql/lib/RecordedCalls.qll
Outdated
Show resolved
Hide resolved
Co-authored-by: Taus <tausbn@github.com>
Was introduced in 5d031d7 when I actually fixed the loop variable capture problem.
tausbn
approved these changes
Sep 7, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.jsonand the README for details.