Skip to content

wip: sql: dynamically disable vectorized execution #146330

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mgartner
Copy link
Collaborator

@mgartner mgartner commented May 7, 2025

No description provided.

Copy link

blathers-crl bot commented May 7, 2025

It looks like your PR touches production code but doesn't add or edit any test code. Did you consider adding tests to your PR?

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@mgartner
Copy link
Collaborator Author

mgartner commented May 7, 2025

Preliminary results:

name                                  old time/op    new time/op    delta
Sysbench/SQL/3node/oltp_point_select     166µs ± 7%     161µs ± 5%    ~     (p=0.095 n=5+5)
Sysbench/SQL/3node/oltp_read_only       2.89ms ± 4%    2.75ms ± 5%    ~     (p=0.056 n=5+5)
Sysbench/SQL/3node/oltp_read_write      7.16ms ± 3%    6.87ms ± 2%  -4.00%  (p=0.008 n=5+5)

name                                  old alloc/op   new alloc/op   delta
Sysbench/SQL/3node/oltp_point_select    25.3kB ± 0%    25.2kB ± 0%  -0.44%  (p=0.032 n=5+5)
Sysbench/SQL/3node/oltp_read_only       1.15MB ± 8%    1.10MB ± 0%  -4.97%  (p=0.016 n=5+5)
Sysbench/SQL/3node/oltp_read_write    2.16MB ± 0%    2.18MB ±19%    ~     (p=1.000 n=4+5)

name                                  old allocs/op  new allocs/op  delta
Sysbench/SQL/3node/oltp_point_select       208 ± 0%       207 ± 0%  -0.48%  (p=0.029 n=4+4)
Sysbench/SQL/3node/oltp_read_only        4.06k ± 3%     3.96k ± 0%  -2.33%  (p=0.008 n=5+5)
Sysbench/SQL/3node/oltp_read_write       10.1k ± 2%      9.8k ± 6%    ~     (p=0.548 n=5+5)

I need to run with a higher --count.

@mgartner
Copy link
Collaborator Author

mgartner commented May 8, 2025

name                                  old time/op    new time/op    delta
Sysbench/SQL/3node/oltp_read_only       2.84ms ± 5%    2.75ms ± 4%  -3.40%  (p=0.019 n=10+10)
Sysbench/SQL/3node/oltp_write_only      4.07ms ± 5%    3.89ms ± 5%  -4.51%  (p=0.011 n=10+10)
Sysbench/SQL/3node/oltp_read_write      7.05ms ± 2%    6.87ms ± 1%  -2.54%  (p=0.000 n=10+8)
Sysbench/SQL/3node/oltp_point_select     162µs ± 5%     163µs ± 3%    ~     (p=0.842 n=10+9)
Sysbench/SQL/3node/oltp_begin_commit    43.4µs ± 3%    43.0µs ± 6%    ~     (p=0.579 n=10+10)

name                                  old errs/op    new errs/op    delta
Sysbench/SQL/3node/oltp_read_only         0.00           0.00         ~     (all equal)
Sysbench/SQL/3node/oltp_write_only        0.00           0.00         ~     (all equal)
Sysbench/SQL/3node/oltp_read_write        0.00           0.00         ~     (all equal)
Sysbench/SQL/3node/oltp_point_select      0.00           0.00         ~     (all equal)
Sysbench/SQL/3node/oltp_begin_commit      0.00           0.00         ~     (all equal)

name                                  old alloc/op   new alloc/op   delta
Sysbench/SQL/3node/oltp_read_only       1.10MB ± 0%    1.10MB ± 0%    ~     (p=0.645 n=8+8)
Sysbench/SQL/3node/oltp_write_only       909kB ±13%     932kB ±14%    ~     (p=0.853 n=10+10)
Sysbench/SQL/3node/oltp_read_write      2.16MB ± 3%    2.25MB ± 8%    ~     (p=0.601 n=7+10)
Sysbench/SQL/3node/oltp_point_select    25.2kB ± 0%    25.2kB ± 0%    ~     (p=0.289 n=10+10)
Sysbench/SQL/3node/oltp_begin_commit    10.4kB ± 0%    10.4kB ± 0%    ~     (p=0.868 n=10+10)

name                                  old allocs/op  new allocs/op  delta
Sysbench/SQL/3node/oltp_read_only        3.97k ± 1%     3.98k ± 1%    ~     (p=0.702 n=8+8)
Sysbench/SQL/3node/oltp_write_only       5.00k ± 6%     4.87k ± 4%  -2.72%  (p=0.022 n=10+10)
Sysbench/SQL/3node/oltp_read_write       10.0k ± 7%      9.8k ± 5%    ~     (p=0.143 n=10+10)
Sysbench/SQL/3node/oltp_point_select       207 ± 0%       207 ± 0%    ~     (p=1.000 n=10+10)
Sysbench/SQL/3node/oltp_begin_commit      55.0 ± 0%      55.0 ± 0%    ~     (all equal)

@mgartner
Copy link
Collaborator Author

mgartner commented May 8, 2025

Upon closer inspection, this change isn't working as intended and vectorization is not disabled. So the results are very suspect. I don't know what would explain these gains.

@mgartner mgartner force-pushed the dynamic-vectorize branch from 10a9b00 to 687f008 Compare May 8, 2025 15:19
@mgartner
Copy link
Collaborator Author

mgartner commented May 8, 2025

I've fixed the issue, and am getting similar results, though slightly better. Probably time for a full sysbench run...

name                                  old time/op    new time/op    delta
Sysbench/SQL/3node/oltp_point_select     165µs ± 2%     152µs ± 6%  -7.85%  (p=0.000 n=8+10)
Sysbench/SQL/3node/oltp_read_only       2.84ms ± 4%    2.75ms ± 6%  -3.12%  (p=0.035 n=10+9)
Sysbench/SQL/3node/oltp_write_only      4.06ms ± 6%    3.89ms ± 5%  -4.07%  (p=0.023 n=10+10)
Sysbench/SQL/3node/oltp_read_write      7.11ms ± 3%    6.91ms ± 2%  -2.76%  (p=0.003 n=10+9)

name                                  old alloc/op   new alloc/op   delta
Sysbench/SQL/3node/oltp_point_select    25.2kB ± 0%    26.6kB ± 1%  +5.23%  (p=0.000 n=9+10)
Sysbench/SQL/3node/oltp_read_only       1.10MB ± 1%    1.11MB ± 0%  +0.84%  (p=0.008 n=8+9)
Sysbench/SQL/3node/oltp_write_only       926kB ±14%     891kB ±14%    ~     (p=0.247 n=10+10)
Sysbench/SQL/3node/oltp_read_write      2.27MB ±10%    2.28MB ±13%    ~     (p=0.529 n=10+10)

name                                  old allocs/op  new allocs/op  delta
Sysbench/SQL/3node/oltp_point_select       207 ± 0%       206 ± 0%  -0.39%  (p=0.009 n=10+10)
Sysbench/SQL/3node/oltp_read_only        4.03k ± 4%     3.96k ± 0%  -1.78%  (p=0.018 n=10+9)
Sysbench/SQL/3node/oltp_write_only       5.01k ± 6%     4.73k ± 5%  -5.47%  (p=0.007 n=10+10)
Sysbench/SQL/3node/oltp_read_write       9.82k ± 6%     9.58k ± 5%    ~     (p=0.109 n=10+9)

@mgartner
Copy link
Collaborator Author

mgartner commented May 8, 2025

I only measured a 1.64% increase in throughput from this.

-------------------------------------
 BEFORE
-------------------------------------
 Run 20250508_174235 - QPS: 22061.40
 Run 20250508_180340 - QPS: 21914.64
 Run 20250508_181509 - QPS: 21826.42
 Run 20250508_182638 - QPS: 21772.46
 Run 20250508_183806 - QPS: 22737.97
 Run 20250508_184934 - QPS: 22714.30
 Mean: 22171.19
 Median: 21988.02
 Standard Deviation: 402.47
 Coefficient of variance: .0183

-------------------------------------
 AFTER
-------------------------------------
 Run 20250508_192033 - QPS: 22315.28
 Run 20250508_193204 - QPS: 22631.58
 Run 20250508_194332 - QPS: 22830.21
 Run 20250508_195459 - QPS: 22460.44
 Run 20250508_200626 - QPS: 22593.65
 Run 20250508_201754 - QPS: 22378.25
 Mean: 22534.90
 Median: 22527.04
 Standard Deviation: 172.39
 Coefficient of variance: .0076

@mgartner
Copy link
Collaborator Author

mgartner commented May 9, 2025

Here's two runs I did without the changes in this PR, for comparison:

-------------------------------------
 vectorize=on
-------------------------------------
 Run 20250509_173918 - QPS: 22518.43
 Run 20250509_180010 - QPS: 22722.36
 Run 20250509_181144 - QPS: 22220.65
 Run 20250509_182318 - QPS: 22265.60
 Run 20250509_183451 - QPS: 22517.04
 Run 20250509_184625 - QPS: 21757.49
 Mean: 22333.59
 Median: 22391.32
 Standard Deviation: 307.74
 Coefficient of variance: .0137

-------------------------------------
 vectorize=off
-------------------------------------
Run 20250509_202802 - QPS: 22175.49
Run 20250509_203934 - QPS: 22227.52
Run 20250509_205107 - QPS: 22104.08
Run 20250509_210240 - QPS: 22290.24
Run 20250509_211414 - QPS: 22104.82
Run 20250509_212547 - QPS: 22126.31
Mean: 22171.41
Median: 22150.90
Standard Deviation: 68.66
Coefficient of variance: .0030

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.

2 participants