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: add cpu nanos to insights tables #96204

Merged
merged 1 commit into from
Jan 31, 2023
Merged

Conversation

maryliag
Copy link
Contributor

@maryliag maryliag commented Jan 30, 2023

Part Of #87213

Add cpu_sql_nanos to
crdb_internal.{cluster,nodes}_execution_insights and crdb_internal.{cluster,nodes}_txn_execution_insights.

Release note: None

@maryliag maryliag requested review from a team and removed request for a team January 30, 2023 17:44
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Contributor

@j82w j82w left a comment

Choose a reason for hiding this comment

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

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


pkg/sql/crdb_internal.go line 6957 at r1 (raw file):

  causes                     STRING[] NOT NULL,
  stmt_execution_ids         STRING[] NOT NULL,
  cpu_nanos                  INT8

Should this be sql_cpu_nanos or something more specific since it doesn't cover cpu time of the entire query like kv layer?


pkg/sql/sqlstats/insights/integration/insights_test.go line 146 at r1 (raw file):

		var startInsights, endInsights time.Time
		var implicitTxn bool
		var cpuNanos int64

Add a check to verify cpu is greater than 0 and less than some large number that should be incorrect.

Copy link
Contributor Author

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

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


pkg/sql/crdb_internal.go line 6957 at r1 (raw file):

Previously, j82w (Jake) wrote…

Should this be sql_cpu_nanos or something more specific since it doesn't cover cpu time of the entire query like kv layer?

I'm keeping consistent with the name on the system/stats tables. We will be adding the remaining info to it, so better to keep like this to avoid a renaming in the future


pkg/sql/sqlstats/insights/integration/insights_test.go line 146 at r1 (raw file):

Previously, j82w (Jake) wrote…

Add a check to verify cpu is greater than 0 and less than some large number that should be incorrect.

Do you have any suggestion about what the large number should be?

Copy link
Contributor Author

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

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


pkg/sql/sqlstats/insights/integration/insights_test.go line 146 at r1 (raw file):

Previously, maryliag (Marylia Gutierrez) wrote…

Do you have any suggestion about what the large number should be?

Just realize this is for a pg_sleep, so I can use that as a base for the time here

@j82w
Copy link
Contributor

j82w commented Jan 30, 2023

pkg/sql/sqlstats/insights/integration/insights_test.go line 146 at r1 (raw file):

Previously, maryliag (Marylia Gutierrez) wrote…

Just realize this is for a pg_sleep, so I can use that as a base for the time here

It shouldn't exceed the elapsed time which can be calculated from the end_time-start_time. I would add 10ms buffer to be on the safe.

@j82w
Copy link
Contributor

j82w commented Jan 30, 2023

pkg/sql/sqlstats/insights/integration/insights_test.go line 146 at r1 (raw file):

Previously, j82w (Jake) wrote…

It shouldn't exceed the elapsed time which can be calculated from the end_time-start_time. I would add 10ms buffer to be on the safe.

Is the actual sleep time included in the cpu time? That seems like possibly a bug if it is because I'm hoping it doesn't hold a cpu that entire time.

Copy link
Contributor Author

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

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


pkg/sql/sqlstats/insights/integration/insights_test.go line 146 at r1 (raw file):

Previously, j82w (Jake) wrote…

Is the actual sleep time included in the cpu time? That seems like possibly a bug if it is because I'm hoping it doesn't hold a cpu that entire time.

is not included, which made me think that the cpu had to be smaller, but your idea is better. Will add the changes

@j82w
Copy link
Contributor

j82w commented Jan 30, 2023

pkg/sql/crdb_internal.go line 6957 at r1 (raw file):

Previously, maryliag (Marylia Gutierrez) wrote…

I'm keeping consistent with the name on the system/stats tables. We will be adding the remaining info to it, so better to keep like this to avoid a renaming in the future

Wouldn't it be better to keep the cpu stats separate to avoid ambiguity? For example if it just says 10.1seconds it would be very different issue if 10s in sql layer and .1s is kv layer vs .1s in sql and 10 sin kv.

@maryliag maryliag requested a review from a team as a code owner January 30, 2023 19:44
@maryliag maryliag requested review from msbutler and removed request for a team and msbutler January 30, 2023 19:44
@j82w
Copy link
Contributor

j82w commented Jan 30, 2023

pkg/ccl/backupccl/testdata/backup-restore/alter-schedule/backup-options line 41 at r2 (raw file):

with schedules as (show schedules) select id, command->'backup_statement' from schedules where label='datatest' order by command->>'backup_type' asc;
----
835701674603675649 "BACKUP INTO 'nodelocal://1/example-schedule' WITH revision_history = false, detached"

Is this right? I don't see anything in the PR touching backup options.

@maryliag maryliag force-pushed the insight-cpu branch 3 times, most recently from de6a322 to 5ff14c1 Compare January 30, 2023 20:21
Copy link
Contributor

@j82w j82w 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 9 of 9 files at r3, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @maryliag)

Part Of cockroachdb#87213

Add `cpu_nanos` to
`crdb_internal.{cluster,nodes}_execution_insights` and
`crdb_internal.{cluster,nodes}_txn_execution_insights`.

Release note: None
Copy link
Contributor

@j82w j82w left a comment

Choose a reason for hiding this comment

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

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

@maryliag
Copy link
Contributor Author

TFTR!
bors r+

@craig
Copy link
Contributor

craig bot commented Jan 31, 2023

Build failed (retrying...):

@craig
Copy link
Contributor

craig bot commented Jan 31, 2023

Build failed (retrying...):

@craig
Copy link
Contributor

craig bot commented Jan 31, 2023

Build failed:

@maryliag
Copy link
Contributor Author

bors r+

@craig craig bot merged commit 58762ac into cockroachdb:master Jan 31, 2023
@craig
Copy link
Contributor

craig bot commented Jan 31, 2023

Build succeeded:

@maryliag maryliag deleted the insight-cpu branch January 31, 2023 21:38
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.

3 participants