Skip to content

Go: Avoid magic in TSynthLocation definition #16172

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 1 commit into from
Apr 10, 2024

Conversation

owen-mc
Copy link
Contributor

@owen-mc owen-mc commented Apr 10, 2024

This fixes a performance problem in code introduced in #15853. The below numbers were obtained on dolthub/go-mysql-server, but I have seen the evaluator do the same optimizations on other projects.

Before:

[2024-04-10 11:18:51] Evaluated non-recursive predicate _Files::File#0e2ffa35_files_locations_default_23451#join_rhs_project#DataFlowUtil::Node.hasLocationI__#antijoin_rhs@212c1fm6 in 23595ms (size: 14907567).
Evaluated relational algebra for predicate _Files::File#0e2ffa35_files_locations_default_23451#join_rhs_project#DataFlowUtil::Node.hasLocationI__#antijoin_rhs@212c1fm6 with tuple counts:
          15168020  ~1%    {5} r1 = SCAN `project#DataFlowUtil::Node.hasLocationInfo/5#dispred#c7d73140` OUTPUT In.1, In.2, In.3, In.4, In.0
        1109162913  ~0%    {6}    | JOIN WITH locations_default_23451#join_rhs ON FIRST 4 OUTPUT Rhs.4, Lhs.4, Lhs.0, Lhs.1, Lhs.2, Lhs.3
        1109162913  ~0%    {6}    | JOIN WITH Files::File#0e2ffa35 ON FIRST 1 OUTPUT Lhs.0, Lhs.1, Lhs.2, Lhs.3, Lhs.4, Lhs.5
          14907567  ~3%    {5}    | JOIN WITH files ON FIRST 2 OUTPUT Lhs.1, Lhs.2, Lhs.3, Lhs.4, Lhs.5
                           return r1

[2024-04-10 11:18:51] Evaluated non-recursive predicate Locations::TSynthLocation#dom#f60a866c@e1167267 in 185ms (size: 260453).
Evaluated relational algebra for predicate Locations::TSynthLocation#dom#f60a866c@e1167267 with tuple counts:
        260453  ~0%    {5} r1 = `project#DataFlowUtil::Node.hasLocationInfo/5#dispred#c7d73140` AND NOT `_Files::File#0e2ffa35_files_locations_default_23451#join_rhs_project#DataFlowUtil::Node.hasLocationI__#antijoin_rhs`(FIRST 5)
                       return r1

After:

[2024-04-10 11:25:05] Evaluated non-recursive predicate Locations::existingDBLocation/5#b5f0485e@3d82ceb2 in 1124ms (size: 15766196).
Evaluated relational algebra for predicate Locations::existingDBLocation/5#b5f0485e@3d82ceb2 with tuple counts:
            1085  ~2%    {2} r1 = JOIN files WITH Files::File#0e2ffa35 ON FIRST 1 OUTPUT Lhs.0, Lhs.1
        15766196  ~2%    {5}    | JOIN WITH locations_default_12345#join_rhs ON FIRST 1 OUTPUT Lhs.1, Rhs.1, Rhs.2, Rhs.3, Rhs.4
                         return r1

and

[2024-04-10 11:25:06] Evaluated non-recursive predicate Locations::TSynthLocation#dom#f60a866c@c135e0ga in 248ms (size: 260453).
Evaluated relational algebra for predicate Locations::TSynthLocation#dom#f60a866c@c135e0ga with tuple counts:
        260453  ~0%    {5} r1 = `project#DataFlowUtil::Node.hasLocationInfo/5#dispred#c7d73140` AND NOT `Locations::existingDBLocation/5#b5f0485e`(FIRST 5)
                       return r1

This improves performance, because in this case magic is not beneficial.
@owen-mc owen-mc added the no-change-note-required This PR does not need a change note label Apr 10, 2024
@owen-mc owen-mc requested a review from hvitved April 10, 2024 10:50
@owen-mc owen-mc requested a review from a team as a code owner April 10, 2024 10:50
@github-actions github-actions bot added the Go label Apr 10, 2024
@owen-mc
Copy link
Contributor Author

owen-mc commented Apr 10, 2024

DCA uneventful.

@owen-mc owen-mc merged commit 0e67aa5 into github:main Apr 10, 2024
14 checks passed
@owen-mc owen-mc deleted the go/perf/synth-location branch April 10, 2024 12:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Go no-change-note-required This PR does not need a change note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants