Sitelet https://web.archive.org/web/20260110110823/https://github.com/github/codeql/pull/4828
Skip to content

Conversation

@yoff
Copy link
Contributor

@yoff yoff commented Dec 15, 2020 •

These are my experiments with source nodes, based on #4622.

Testing current performance here: Job, results

The performance gains are similar to what @tausbn achieved, but we should also check the pathological snapshots.

Differences job tuning on projects that previously timed out: Job
That job result was not illuminating to me. But I could locally run the sql injection query on FreeCAD in about 100 minutes (6400.015 seconds).

Differences job for import change: Job

tausbn and others added 11 commits November 5, 2020 16:26
This fixes the major performance problem with type tracking on
some (pathological) databases.

The interface could probably be improved a bit. In particular, I'm
thinking that we might want to have `DataFlow::exprNode` return a
`LocalSourceNode` so that a cast isn't necessary in order to use
`flowsTo`.

I have added two `cached` annotations. The one on `flowsTo` is
crucial, as performance regresses without it. The one on
`simpleLocalFlowStep` may not be needed, but Java has a similar
annotation, and to me it makes sense to have this relation cached.
This is only _really_ expensive when there are a _lot_ of strings in
the database, but for this case, where we're always extracting the
same substring of the string, it's easier -- and faster -- to just
make a substring operation directly.
Since the number of relevant attributes in the `re` module is fairly
small, it made sense to factor this out in a separate predicate, and
the join order also became more sensible.
Here, `context.appliesTo(n)` was being distributed across all of the
disjuncts, which caused poor performance.

The new helper predicate, `literal_node_class` should be fairly small,
since it only applies to a subset of `ControlFlowNode`s, and only
assigns a limited set of `ClassObjectInternal`s to these nodes.
Also fixes a bug ("`B`" was not recognised as a bytestring prefix).

The basic idea behind this fix is that the set of possible prefixes is
fairly small, so it's easier just to precompute them, and then join
them with the entire prefix of the string in question (rather than
look at each string in isolation, get its prefix, and _then_ check
whether it looks like it's a unicode string prefix, which essentially
is what the code did before).
This has no impact on performance, but it cleans up the code a bit,
and (hopefully) makes it more readable.
…aFlowPrivate.qll`

Co-authored-by: yoff <lerchedahl@gmail.com>
This is against the philosophy, but we
have still restricted attributes.
We use this PR to test performance.
yoff added 3 commits December 18, 2020 13:30
This also reverts the previous commit.
It should be squashed with that one, but for now we keep the history,
so we can track the performance tests.
@yoff yoff added the Awaiting evaluation Do not merge yet, this PR is waiting for an evaluation to finish label Jan 4, 2021
@yoff yoff marked this pull request as ready for review January 4, 2021 15:44
@yoff yoff requested a review from a team as a code owner January 4, 2021 15:44
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.

Looks good to me, and tests and performance seem good as well. Merging.

@tausbn tausbn merged commit 75cfec8 into github:main Jan 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Awaiting evaluation Do not merge yet, this PR is waiting for an evaluation to finish Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants