-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #12235 performance regression (hang) in 2.13dev #5715
Conversation
I'm not quite sure about the fix. There might also be something else that's going wrong. |
We have this in
It seems that we (incorrectly?) returned true from |
When |
The |
test/cli/test-other.py
Outdated
@@ -152,6 +152,45 @@ def test_progress_j(tmpdir): | |||
assert stdout == "Checking {} ...\n".format(test_file) | |||
assert stderr == "" | |||
|
|||
@pytest.mark.timeout(10) | |||
def test_slow_initlist_varchanged(tmpdir): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the test-performance.py for the performance tests.
looks good to me. |
lib/astutils.cpp
Outdated
@@ -2806,7 +2806,8 @@ Token* findVariableChanged(Token *start, const Token *end, int indirect, const n | |||
if (depth < 0) | |||
return start; | |||
auto getExprTok = memoize([&] { | |||
return findExpression(start, exprid); | |||
const auto* e = findExpression(start, exprid); | |||
return e ? e : start; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It shouldn't return start
. It supposed to return the token that has that exprid or nullptr
if it can't be found.
I dont really understand how this would fix a hang though as you are still calling findExpression
. As a perf improvement we could probably skip searching of a variable changed if its already a unique expression id.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah sorry, I see your other comment on why you did this, but it still shouldn't return start
as that is wrong.
Yea we could skip those in static bool isExpressionChangedAt(const F& getExprTok,
const Token* tok,
int indirect,
const nonneg int exprid,
bool globalvar,
const Settings* settings,
bool cpp,
int depth)
{
if (depth < 0)
return true;
if (tok->isLiteral() || tok->isKeyword() || Token::Match(tok, ",|;|:|%type%"))
return false;
if (tok->exprId() != exprid) {
...
}
return (isVariableChanged(tok, indirect, settings, cpp, depth));
} This could probably be extended to skip more things such as variable declarations, case labels or control flow parenthesis(ie |
Looks like that was enough to pass the test. |
We probably need to use Another thing, is to call |
Running the test with |
Great work, everybody! @danmar I know a release is imminent but we should let this soak a few days so we get updated daca results and can see if there is something else left in terms of performance regressions. I already started a run to update the known regression. |
No description provided.