Skip to content

Conversation

jbj
Copy link
Contributor

@jbj jbj commented Oct 5, 2018

This is an attempt to fix the timeouts we've seen in Dashboards/Internal in the last few days. I'm aiming this at 1.18.1 because the second commit fixes a regression introduced in #123 that might affect customers -- see the discussion in CPP-279.

The first commit is not a regression fix but should be Nice To Have. I've tested it for correctness by comparing the output of select strictcount(PrimitiveBasicBlock b) before and after. The implementation is ported from the Java basic-blocks library.

jbj added 2 commits October 5, 2018 14:20
The existing implementation of `primitive_basic_block_entry_node` was
"cleverly" computing two properties about `node` with a single
`strictcount`: whether `node` had multiple predecessors and whether any
of those predecessors had more than once successor. This was fast enough
on most snapshots, but on the snapshot of our own code it took 37
seconds to compute `primitive_basic_block_entry_node` and its auxiliary
predicates. This is likely to have affected other large snapshots too.

With this change, the property is computed like in our other languages,
and it brings the run time down to 4 seconds.
This predicate looked like a join of two already-computed predicates,
but it was a bit more complicated because the `*` operator expands into
two cases: the reflexive case and the transitive case. The join order
for the transitive case placed the `PrimitiveBasicBlock` charpred call
_after_ the `member_step+` call, which means that all the tuples of
`member_step+` passed through the pipeline.

This commit changes the implementation by fully writing out the
expansion of `*` into two cases, where the base case is manually
specialised to make sure the join orderer doesn't get tempted into
reusing the same strategy for both cases. This speeds up the predicate
from 2m38s to 1s on a snapshot of our own C/C++ code.
@jbj jbj added the C++ label Oct 5, 2018
@jbj jbj added this to the 1.18 milestone Oct 5, 2018
Copy link
Contributor

@geoffw0 geoffw0 left a comment

Choose a reason for hiding this comment

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

Changes LGTM.

I tried a few basic-blocks using queries with and without the change, they generally ran at the same speed or a bit faster. I probably didn't hit any extreme cases.

@geoffw0 geoffw0 merged commit e2a001f into github:rc/1.18 Oct 6, 2018
smowton added a commit to smowton/codeql that referenced this pull request Apr 16, 2022
Switch to expanding property initializers and init blocks in-place
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.

2 participants