Skip to content
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

sql: reduce the overhead of EXPLAIN ANALYZE #91117

Merged
merged 1 commit into from
Nov 3, 2022

Conversation

yuzefovich
Copy link
Member

@yuzefovich yuzefovich commented Nov 2, 2022

In order to propagate the execution stats across the distributed query plan we use the tracing infrastructure, where each stats object is added as "structured metadata" to the trace. Thus, whenever we're collecting the exec stats for a statement, we must enable tracing. Previously, in many cases we would enable it at the highest verbosity level which has non-trivial overhead. In some cases this was an overkill (e.g. in EXPLAIN ANALYZE we don't really care about the trace containing all of the gory details - we won't expose it anyway), so this is now fixed by using the less verbose "structured" verbosity level. As a concrete example of the difference: for a stmt that without EXPLAIN ANALYZE takes around 190ms, with EXPLAIN ANALYZE it would previously run for about 1.8s and now it takes around 210ms.

This required some minor changes to the row-by-row outbox and router
setups to collect thats even if the recording is not verbose.

Addresses: #90739.

Epic: CRDB-14510

Release note (performance improvement): The overhead of running EXPLAIN ANALYZE and EXPLAIN ANALYZE (DISTSQL) has been significantly reduced. The overhead of EXPLAIN ANALYZE (DEBUG) didn't change.

@yuzefovich yuzefovich requested review from michae2 and a team November 2, 2022 02:10
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Collaborator

@DrewKimball DrewKimball left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @michae2)

Copy link
Collaborator

@michae2 michae2 left a comment

Choose a reason for hiding this comment

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

:lgtm: Thank you!

Reviewed 1 of 1 files at r1, all commit messages.
Reviewable status: :shipit: complete! 2 of 0 LGTMs obtained (waiting on @yuzefovich)

In order to propagate the execution stats across the distributed query
plan we use the tracing infrastructure, where each stats object is added
as "structured metadata" to the trace. Thus, whenever we're collecting
the exec stats for a statement, we must enable tracing. Previously, in
many cases we would enable it at the highest verbosity level which has
non-trivial overhead. In some cases this was an overkill (e.g. in
`EXPLAIN ANALYZE` we don't really care about the trace containing all of
the gory details - we won't expose it anyway), so this is now fixed by
using the less verbose "structured" verbosity level. As a concrete
example of the difference: for a stmt that without `EXPLAIN ANALYZE`
takes around 190ms, with `EXPLAIN ANALYZE` it would previously run for
about 1.8s and now it takes around 210ms.

This required some minor changes to the row-by-row outbox and router
setups to collect thats even if the recording is not verbose.

Release note (performance improvement): The overhead of running
`EXPLAIN ANALYZE` and `EXPLAIN ANALYZE (DISTSQL)` has been significantly
reduced. The overhead of `EXPLAIN ANALYZE (DEBUG)` didn't change.
@yuzefovich
Copy link
Member Author

I needed to make some minor tweaks.

I wonder though - should this PR completely close #90739? It seems like EXPLAIN ANALYZE overhead will now be minor, and this is what that issue seems to be mostly about. The large overhead of (DEBUG) option seems expected. Thoughts?

@michae2
Copy link
Collaborator

michae2 commented Nov 2, 2022

I needed to make some minor tweaks.

I wonder though - should this PR completely close #90739? It seems like EXPLAIN ANALYZE overhead will now be minor, and this is what that issue seems to be mostly about. The large overhead of (DEBUG) option seems expected. Thoughts?

The original slack thread included a statement bundle. I wrote EXPLAIN ANALYZE rather than EXPLAIN ANALYZE (DEBUG) in the GH issue because it was a simpler repro, but I think the fundamental problem applies to both. I propose we keep the issue open, but change it to be about EXPLAIN ANALYZE (DEBUG), so that we have a place to point people when they ask why their bundle is so much slower.

Copy link
Collaborator

@michae2 michae2 left a comment

Choose a reason for hiding this comment

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

:lgtm: Thank you again!

Reviewed 4 of 4 files at r2, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (and 1 stale) (waiting on @yuzefovich)

@yuzefovich
Copy link
Member Author

TFTRs!

bors r+

@craig
Copy link
Contributor

craig bot commented Nov 3, 2022

This PR was included in a batch that timed out, it will be automatically retried

@craig
Copy link
Contributor

craig bot commented Nov 3, 2022

Build succeeded:

@craig craig bot merged commit 9c9d55d into cockroachdb:master Nov 3, 2022
@blathers-crl
Copy link

blathers-crl bot commented Nov 3, 2022

Encountered an error creating backports. Some common things that can go wrong:

  1. The backport branch might have already existed.
  2. There was a merge conflict.
  3. The backport branch contained merge commits.

You might need to create your backport manually using the backport tool.


error creating merge commit from 98ee45d to blathers/backport-release-22.1-91117: POST https://api.github.com/repos/cockroachdb/cockroach/merges: 409 Merge conflict []

you may need to manually resolve merge conflicts with the backport tool.

Backport to branch 22.1.x failed. See errors above.


error creating merge commit from 98ee45d to blathers/backport-release-22.2-91117: POST https://api.github.com/repos/cockroachdb/cockroach/merges: 409 Merge conflict []

you may need to manually resolve merge conflicts with the backport tool.

Backport to branch 22.2.x failed. See errors above.


🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants