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: use parsed statements for persistedsqlstats #139171

Merged
merged 1 commit into from
Jan 17, 2025

Conversation

fqazi
Copy link
Collaborator

@fqazi fqazi commented Jan 15, 2025

Previously, we would re-parse SQL statements used to upsert statement and txn stats. To address this patch, this patch will parse these statements once and use ExecParsed to reduce CPU usage. This patch also adds a simple benchmark for this code path as well, which shows a small 1% delta.

Before:
BenchmarkSQLStatsFlush 100 1415926687 ns/op 319339313 B/op 2302002 allocs/op
After:
BenchmarkSQLStatsFlush 100 1396673170 ns/op 319003310 B/op 2298192 allocs/op

Fixes: #134583
Release note: None

@fqazi fqazi requested a review from dhartunian January 15, 2025 19:54
@fqazi fqazi requested a review from a team as a code owner January 15, 2025 19:54
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Previously, we would re-parse SQL statements used to upsert statement
and txn stats. To address this patch, this patch will parse these
statements once and use ExecParsed to reduce CPU usage. This patch also
adds a simple benchmark for this code path as well, which shows a small
1% delta.

Before:
BenchmarkSQLStatsFlush          100        1415926687 ns/op        319339313 B/op   2302002 allocs/op
After:
BenchmarkSQLStatsFlush          100        1396673170 ns/op        319003310 B/op   2298192 allocs/op

Fixes: cockroachdb#134583
Release note: None
@fqazi fqazi force-pushed the avoidFlushReparse branch from 2b2254d to 7362ad9 Compare January 15, 2025 20:04
Copy link
Member

@xinhaoz xinhaoz left a comment

Choose a reason for hiding this comment

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

Awesome, thank you for this improvement!

@fqazi
Copy link
Collaborator Author

fqazi commented Jan 17, 2025

@xinhaoz TFTR!

bors r+

@craig craig bot merged commit 286abc2 into cockroachdb:master Jan 17, 2025
22 checks passed
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.

sqlstats: do not reparse flush statements on every execution (0.1% cpu)
3 participants