Skip to content

Python: avoid selecting getLocation() #13371

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

Merged
merged 2 commits into from
Jun 6, 2023
Merged

Conversation

nickrolfe
Copy link
Contributor

For Python this doesn't seem to be as disastrous as for C# and Java: the evaluator logs suggest Location::toString() was getting magicked in UnnecessaryDelete.ql, so it wasn't causing any performance issues, but I've fixed it anyway.

For TruncatedDivision.ql, meanwhile, this change means we avoid generating these predicates:

[2023-06-05 10:48:09] Evaluated non-recursive predicate Files#a547fcb4::Location::toString#0#dispred#ff@cb160078 in 2432ms (size: 2278502).
Evaluated relational algebra for predicate Files#a547fcb4::Location::toString#0#dispred#ff@cb160078 with tuple counts:
              0   ~0%    {2} r1 = SCAN Files#a547fcb4::EncodingError#f OUTPUT In.0, "Encoding Error"
                     
              0   ~0%    {2} r2 = SCAN Files#a547fcb4::SyntaxError#f OUTPUT In.0, "Syntax Error"
              0   ~0%    {2} r3 = r2 AND NOT Files#a547fcb4::EncodingError#f(Lhs.0)
                     
        2278502   ~3%    {2} r4 = SCAN Files#a547fcb4::Location::getPath#0#dispred#ff OUTPUT In.1, In.0
        2278502   ~2%    {2} r5 = JOIN r4 WITH Files#a547fcb4::Container::getAbsolutePath#0#dispred#ff ON FIRST 1 OUTPUT Lhs.1, Rhs.1
        2278502   ~2%    {2} r6 = r5 AND NOT Files#a547fcb4::SyntaxError#f(Lhs.0)
        2278502   ~5%    {2} r7 = JOIN r6 WITH Files#a547fcb4::Location::getStartLine#0#dispred#ff ON FIRST 1 OUTPUT Lhs.0, (Lhs.1 ++ ":" ++ toString(Rhs.1))
                     
        2278502   ~5%    {2} r8 = r3 UNION r7
        2278502   ~5%    {2} r9 = r1 UNION r8
                         return r9

[2023-06-05 10:48:09] Evaluated non-recursive predicate project#Files#a547fcb4::Location::toString#0#dispred#ff@68e576a6 in 54ms (size: 2278502).
Evaluated relational algebra for predicate project#Files#a547fcb4::Location::toString#0#dispred#ff@68e576a6 with tuple counts:
        2278502  ~0%    {1} r1 = SCAN Files#a547fcb4::Location::toString#0#dispred#ff OUTPUT In.0
        2278502  ~0%    {1} r2 = STREAM DEDUP r1
                        return r2

@nickrolfe nickrolfe requested a review from a team as a code owner June 5, 2023 10:23
@nickrolfe nickrolfe added the no-change-note-required This PR does not need a change note label Jun 5, 2023
@nickrolfe nickrolfe force-pushed the nickrolfe/python-location-tostring branch from 453820e to 0239586 Compare June 5, 2023 12:43
@calumgrant calumgrant requested a review from tausbn June 6, 2023 09:27
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.

Thanks! I wonder why we did it this way in the first place.
Just one of life's little mysteries, I guess.

@tausbn tausbn merged commit c4bfb21 into main Jun 6, 2023
@tausbn tausbn deleted the nickrolfe/python-location-tostring branch June 6, 2023 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-change-note-required This PR does not need a change note Python
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants