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: record sql CPU nanoseconds in statement statistics table #95639

Merged
merged 1 commit into from
Jan 24, 2023

Conversation

DrewKimball
Copy link
Collaborator

@DrewKimball DrewKimball commented Jan 21, 2023

This patch adds a cpu_nanos field to the crdb_internal and system statement and transaction statistics tables that tracks the CPU time in nanoseconds spent during SQL execution. Note that similar to disk and memory usage, CPU time is tracked on a sampling basis. Future work will display this field in the UI.

Informs #87213

Release note (sql change): Added a cpuNanos field to the statistics column of the crdb_internal.statement_statistics and system.statement_statistics tables that reports the amount of CPU time in nanoseconds during SQL execution for queries that track CPU time.

@DrewKimball DrewKimball requested review from maryliag, yuzefovich and a team January 21, 2023 03:57
@DrewKimball DrewKimball requested a review from a team as a code owner January 21, 2023 03:57
@DrewKimball DrewKimball requested a review from a team January 21, 2023 03:57
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Contributor

@maryliag maryliag left a comment

Choose a reason for hiding this comment

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

Looks great!
You're missing some updates on statements.spec.tsx and appStats.spec.ts, and some nits to deal with the lint errors.
Otherwise :lgtm:

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


pkg/ui/workspaces/cluster-ui/src/util/appStats/appStats.ts line 129 at r1 (raw file):

      countA,
      countB,
    )

nit: you will get a lint error if you don't add , here


pkg/ui/workspaces/cluster-ui/src/statementsPage/statementsPage.fixture.ts line 51 at r1 (raw file):

    mean: 80,
    squared_diffs: 0.01,
  }

nit: add , (lint error)


pkg/ui/workspaces/cluster-ui/src/util/totalWorkload.fixture.ts line 47 at r1 (raw file):

    mean: 4160407,
    squared_diffs: 47880000000000,
  }

nit: add , (lint error)

Copy link
Member

@yuzefovich yuzefovich left a comment

Choose a reason for hiding this comment

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

:lgtm:

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


-- commits line 4 at r1:
nit: these tables are not "system" but are virtual internal, right?

Copy link
Collaborator Author

@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.

Reviewable status: :shipit: complete! 2 of 0 LGTMs obtained (waiting on @yuzefovich)


-- commits line 4 at r1:

Previously, yuzefovich (Yahor Yuzefovich) wrote…

nit: these tables are not "system" but are virtual internal, right?

Changed "system" to "internal".


pkg/ui/workspaces/cluster-ui/src/util/appStats/appStats.ts line 129 at r1 (raw file):

Previously, maryliag (Marylia Gutierrez) wrote…

nit: you will get a lint error if you don't add , here

Done.


pkg/ui/workspaces/cluster-ui/src/statementsPage/statementsPage.fixture.ts line 51 at r1 (raw file):

Previously, maryliag (Marylia Gutierrez) wrote…

nit: add , (lint error)

Done.


pkg/ui/workspaces/cluster-ui/src/util/totalWorkload.fixture.ts line 47 at r1 (raw file):

Previously, maryliag (Marylia Gutierrez) wrote…

nit: add , (lint error)

Done.

Copy link
Contributor

@maryliag maryliag left a comment

Choose a reason for hiding this comment

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

Reviewed 5 of 5 files at r2.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 2 stale) (waiting on @DrewKimball and @yuzefovich)


-- commits line 4 at r1:

Previously, DrewKimball (Drew Kimball) wrote…

Changed "system" to "internal".

actually is both, because exists in crdb_internal and then gets flushed to system table, so users can see this data in both places.
The changes added here will affect both tables, so you can keep the description for both. (same thing for the release note)

This patch adds a `cpu_nanos` field to the `crdb_internal` and `system`
statement and transaction statistics tables that tracks the CPU time in
nanoseconds spent during SQL execution. Note that similar to disk and
memory usage, CPU time is tracked on a sampling basis. Future work will
display this field in the UI.

Informs cockroachdb#87213

Release note (sql change): Added a `cpuNanos` field to the statistics
column of the `crdb_internal.statement_statistics` and
`system.statement_statistics` tables that reports the amount of CPU
time in nanoseconds during SQL execution for queries that track CPU time.
Copy link
Collaborator Author

@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.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 2 stale) (waiting on @maryliag and @yuzefovich)


-- commits line 4 at r1:

Previously, maryliag (Marylia Gutierrez) wrote…

actually is both, because exists in crdb_internal and then gets flushed to system table, so users can see this data in both places.
The changes added here will affect both tables, so you can keep the description for both. (same thing for the release note)

Updated the descriptions to refer to both.

@DrewKimball
Copy link
Collaborator Author

TFTRs!

bors r+

@craig
Copy link
Contributor

craig bot commented Jan 24, 2023

Build failed:

@DrewKimball
Copy link
Collaborator Author

Looks like a flake.

bors r+

@craig
Copy link
Contributor

craig bot commented Jan 24, 2023

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

@craig
Copy link
Contributor

craig bot commented Jan 24, 2023

Build succeeded:

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