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

Reduce VTGate Normalizer multiple AST walks #17619

Merged
merged 2 commits into from
Jan 23, 2025

Conversation

harshit-gangal
Copy link
Member

@harshit-gangal harshit-gangal commented Jan 23, 2025

Description

This PR reduces the ast walk in VTGate normalizer code.

Benchmark shows ~5% normalizer improvement

goos: darwin
goarch: arm64
pkg: vitess.io/vitess/go/vt/sqlparser
cpu: Apple M1 Max
                                     │ /Users/planetscale/benchmark/v2.txt │ /Users/planetscale/benchmark/v3.txt │
                                     │               sec/op                │    sec/op     vs base               │
Normalize-4                                                    1.217µ ± 5%    1.103µ ± 1%   -9.41% (p=0.002 n=6)
NormalizeTraces/django_queries.txt-4                           185.9µ ± 2%    167.3µ ± 1%  -10.04% (p=0.002 n=6)
NormalizeTraces/lobsters.sql.gz-4                              9.613m ± 3%    8.348m ± 2%  -13.16% (p=0.002 n=6)
NormalizeVTGate-4                                              71.89m ± 1%    70.74m ± 1%   -1.60% (p=0.041 n=6)
NormalizeTPCCBinds-4                                           18.04µ ± 1%    17.97µ ± 1%        ~ (p=0.093 n=6)
NormalizeTPCCInsert-4                                          63.65m ± 2%    63.75m ± 1%        ~ (p=0.937 n=6)
NormalizeTPCC-4                                                51.59m ± 1%    50.73m ± 2%   -1.67% (p=0.026 n=6)
geomean                                                        1.374m         1.302m        -5.30%

                                     │ /Users/planetscale/benchmark/v2.txt │ /Users/planetscale/benchmark/v3.txt │
                                     │                B/op                 │     B/op      vs base               │
NormalizeTraces/django_queries.txt-4                          178.3Ki ± 0%   167.1Ki ± 0%   -6.28% (p=0.002 n=6)
NormalizeTraces/lobsters.sql.gz-4                             7.072Mi ± 0%   6.277Mi ± 0%  -11.25% (p=0.002 n=6)
NormalizeVTGate-4                                             48.27Mi ± 0%   47.46Mi ± 0%   -1.67% (p=0.002 n=6)
NormalizeTPCCBinds-4                                          11.35Ki ± 0%   11.36Ki ± 0%   +0.13% (p=0.002 n=6)
NormalizeTPCCInsert-4                                         50.63Mi ± 0%   50.65Mi ± 0%   +0.04% (p=0.002 n=6)
NormalizeTPCC-4                                               35.77Mi ± 0%   35.40Mi ± 0%   -1.02% (p=0.002 n=6)
geomean                                                       3.257Mi        3.145Mi        -3.43%

                                     │ /Users/planetscale/benchmark/v2.txt │ /Users/planetscale/benchmark/v3.txt  │
                                     │              allocs/op              │  allocs/op   vs base                 │
NormalizeTraces/django_queries.txt-4                           6.025k ± 0%   5.389k ± 0%  -10.56% (p=0.002 n=6)
NormalizeTraces/lobsters.sql.gz-4                              252.3k ± 0%   213.2k ± 0%  -15.49% (p=0.002 n=6)
NormalizeVTGate-4                                              1.112M ± 0%   1.073M ± 0%   -3.51% (p=0.002 n=6)
NormalizeTPCCBinds-4                                            301.0 ± 0%    301.0 ± 0%        ~ (p=1.000 n=6) ¹
NormalizeTPCCInsert-4                                          958.0k ± 0%   958.0k ± 0%        ~ (p=0.671 n=6)
NormalizeTPCC-4                                                836.9k ± 0%   818.5k ± 0%   -2.20% (p=0.002 n=6)
geomean                                                        86.11k        81.40k        -5.48%
¹ all samples are equal

Related Issue(s)

Checklist

  • Tests were added or are not required
  • Did the new or modified tests pass consistently locally and on CI?
  • Documentation was added or is not required

Deployment Notes

Copy link
Contributor

vitess-bot bot commented Jan 23, 2025

Review Checklist

Hello reviewers! 👋 Please follow this checklist when reviewing this Pull Request.

General

  • Ensure that the Pull Request has a descriptive title.
  • Ensure there is a link to an issue (except for internal cleanup and flaky test fixes), new features should have an RFC that documents use cases and test cases.

Tests

  • Bug fixes should have at least one unit or end-to-end test, enhancement and new features should have a sufficient number of tests.

Documentation

  • Apply the release notes (needs details) label if users need to know about this change.
  • New features should be documented.
  • There should be some code comments as to why things are implemented the way they are.
  • There should be a comment at the top of each new or modified test to explain what the test does.

New flags

  • Is this flag really necessary?
  • Flag names must be clear and intuitive, use dashes (-), and have a clear help text.

If a workflow is added or modified:

  • Each item in Jobs should be named in order to mark it as required.
  • If the workflow needs to be marked as required, the maintainer team must be notified.

Backward compatibility

  • Protobuf changes should be wire-compatible.
  • Changes to _vt tables and RPCs need to be backward compatible.
  • RPC changes should be compatible with vitess-operator
  • If a flag is removed, then it should also be removed from vitess-operator and arewefastyet, if used there.
  • vtctl command output order should be stable and awk-able.

@vitess-bot vitess-bot bot added NeedsBackportReason If backport labels have been applied to a PR, a justification is required NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsIssue A linked issue is missing for this Pull Request NeedsWebsiteDocsUpdate What it says labels Jan 23, 2025
@harshit-gangal harshit-gangal removed NeedsWebsiteDocsUpdate What it says NeedsIssue A linked issue is missing for this Pull Request NeedsBackportReason If backport labels have been applied to a PR, a justification is required labels Jan 23, 2025
@github-actions github-actions bot added this to the v22.0.0 milestone Jan 23, 2025
@harshit-gangal harshit-gangal added Component: Query Serving Type: Performance and removed NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work labels Jan 23, 2025
@harshit-gangal harshit-gangal marked this pull request as ready for review January 23, 2025 13:29
Copy link

codecov bot commented Jan 23, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 67.64%. Comparing base (1d57f39) to head (99aec4f).
Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #17619      +/-   ##
==========================================
- Coverage   67.68%   67.64%   -0.05%     
==========================================
  Files        1586     1586              
  Lines      255413   255466      +53     
==========================================
- Hits       172883   172803      -80     
- Misses      82530    82663     +133     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@systay systay merged commit 43e6089 into vitessio:main Jan 23, 2025
112 of 115 checks passed
@systay systay deleted the normalizer-changes branch January 23, 2025 15:43
@harshit-gangal harshit-gangal added the Benchmark me Add label to PR to run benchmarks label Jan 23, 2025
Copy link
Contributor

vitess-bot bot commented Jan 23, 2025

Hello! 👋

This Pull Request is now handled by arewefastyet. The current HEAD and future commits will be benchmarked.

You can find the performance comparison on the arewefastyet website.

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

Successfully merging this pull request may close these issues.

3 participants