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

Inline ops that read settings #245

Merged
merged 1 commit into from
Apr 20, 2023

Conversation

miguelff
Copy link
Contributor

@miguelff miguelff commented Apr 20, 2023

Before this patch, fetching @@socket, @@max_allowed_packet, and @@wait_timeout was done in separate queries. This means that in the worst case scenario, stablishing a connection required 3 extra roundtrips to the server.

This patch inlines those three operations into one, assuming the query will be equally complex, all the settings are queried as long as one of them is needed.

Some results, from the commit message:

Measures taken on 100 coldstart connections to a remote RDS mysql 5.7 in us-east-1, accessed from Spain. Units are ms.

Before patch:

Average: 222.01605959
Standard deviation: 20.28249939282523

After patch:

Average: 152.8317912
Standard deviation: 22.382571070107467

Inlining queries make connections that require reading server settings run ~30% faster.

Measures taken on 100 coldstart connections to a remote RDS mysql 5.7 in us-east-1, accessed from Spain. Units are ms.

Before patch:

Average: 222.01605959
Standard deviation: 20.28249939282523

After patch:

Average: 152.8317912
Standard deviation: 22.382571070107467

Inlining queries make connections that require reading server settings run ~30% faster.
@blackbeam blackbeam merged commit 5843e91 into blackbeam:master Apr 20, 2023
L-jasmine added a commit to second-state/mysql_async_wasi that referenced this pull request Dec 21, 2023
commit 514d6db
Author: Anatoly Ikorsky <aikorsky@gmail.com>
Date:   Wed Nov 8 18:39:50 2023 +0300

    Document the binlog feature

commit a8be430
Merge: 7c221d7 e5b07df
Author: Anatoly I <aikorsky@gmail.com>
Date:   Wed Nov 8 17:53:57 2023 +0300

    Merge pull request blackbeam#263 from blackbeam/release-0.33.0

    Release 0.33.0

commit e5b07df
Author: Anatoly Ikorsky <aikorsky@gmail.com>
Date:   Wed Nov 8 12:20:59 2023 +0300

    Bump lru version

commit f8e0bd5
Author: Anatoly Ikorsky <aikorsky@gmail.com>
Date:   Wed Nov 8 11:51:09 2023 +0300

    Clippy

commit 9d08837
Author: Anatoly Ikorsky <aikorsky@gmail.com>
Date:   Wed Nov 8 10:44:11 2023 +0300

    Fix docstrings

commit 7c221d7
Merge: 02e47d9 4023e5e
Author: Anatoly I <aikorsky@gmail.com>
Date:   Wed Nov 8 10:26:53 2023 +0300

    Merge pull request blackbeam#264 from web3creator/master

     add ResultSetStream types export

commit 4023e5e
Author: Anatoly Ikorsky <aikorsky@gmail.com>
Date:   Tue Nov 7 15:03:30 2023 +0300

    Style ResultSetStream::{columns, columns_ref} in accordance with the rest of the project

commit fcb25d9
Author: simon <askforsimonyi@gmail.com>
Date:   Tue Nov 7 01:11:42 2023 +0800

     add ResultSetStream types export

commit 5e94f56
Author: Anatoly Ikorsky <aikorsky@gmail.com>
Date:   Thu Nov 2 17:21:16 2023 +0300

    Bump version

commit 0e84bd1
Author: Anatoly Ikorsky <aikorsky@gmail.com>
Date:   Thu Nov 2 17:15:13 2023 +0300

    Bump mysql_common

commit 829774f
Author: Anatoly Ikorsky <aikorsky@gmail.com>
Date:   Tue Oct 24 17:18:51 2023 +0300

    Hide binlog behind a feature

commit 439fec4
Author: Anatoly Ikorsky <aikorsky@gmail.com>
Date:   Mon Oct 23 18:32:02 2023 +0300

    Introduce `BinlogStreamRequest`

commit 02e47d9
Merge: e9e037b ec1a698
Author: Anatoly I <aikorsky@gmail.com>
Date:   Mon Sep 18 11:34:38 2023 +0300

    Merge pull request blackbeam#258 from cloneable/absolute-connection-ttl

    Option to set an absolute TTL for connections

commit ec1a698
Author: Folke Behrens <folke@gmail.com>
Date:   Thu Aug 31 18:02:55 2023 +0200

    Option to set an absolute TTL for connections

    * The TTL, if set, forces connections to be disconnected, even
      overriding the minimum pool size constraint.
    * The TTL can be combined with a random jitter value to prevent
      all connections closing at the same time.
    * This enables gradual connection migration and regular connection
      recycling when CONN_RESET on return to pool is not desired.

commit e9e037b
Merge: 815971f 421ad9d
Author: Anatoly I <aikorsky@gmail.com>
Date:   Sun Sep 17 13:06:12 2023 +0300

    Merge pull request blackbeam#255 from DK26/master

    Fixed spelling mistake in doc-comments

commit 815971f
Author: Anatoly Ikorsky <aikorsky@gmail.com>
Date:   Thu Sep 14 16:14:39 2023 +0300

    Fix build for updated webpki-roots

commit c5f620e
Author: Anatoly Ikorsky <aikorsky@gmail.com>
Date:   Thu Sep 14 11:33:40 2023 +0300

    Bump `lru` and `pem` deps

commit da2193b
Author: Anatoly Ikorsky <aikorsky@gmail.com>
Date:   Thu Sep 14 11:30:40 2023 +0300

    Bump webpki (fix blackbeam#256)

commit 31d040f
Author: Anatoly Ikorsky <aikorsky@gmail.com>
Date:   Thu Sep 14 11:16:50 2023 +0300

    get_opts_db_name_from_url: use Option::filter instead of and_then

commit 4f09530
Merge: f3cdaa0 2a716a6
Author: Anatoly I <aikorsky@gmail.com>
Date:   Sat Sep 9 08:56:32 2023 +0300

    Merge pull request blackbeam#259 from altmannmarcelo/empty-db

    Usability improvement: leading forward slash empty database

commit 2a716a6
Author: Marcelo Altmann <marcelo.altmann@percona.com>
Date:   Fri Sep 8 15:51:04 2023 -0300

    Usability improvement: leading forward slash empty database

    A leading forward slash in the connection URL makes
    get_opts_db_name_from_url set db_name to Some("") rather than None.
    This makes code pulling the db from config requiring extra checks as
    db_name.is_some() will evaluate to true.
    Empty database parameter is invalid for MySQL.

commit 421ad9d
Author: David Krasnitsky <DK26@users.noreply.github.com>
Date:   Sun Aug 20 13:41:16 2023 +0300

    Fixed spelling mistake in doc-comments

    I found a spelling-mistake in the doc comments where `Executes` is misspelled as `Exectues` of the following methods:

    `exec_batch()`
    `exec()`
    `exec_first()`
    `exec_map()`
    `exec_fold()`
    `exec_drop()`

commit f3cdaa0
Merge: ddee16e 668a7e4
Author: Anatoly I <aikorsky@gmail.com>
Date:   Mon Aug 7 10:09:56 2023 +0300

    Merge pull request blackbeam#254 from blackbeam/issue-253

    Do not read unnecessary settings in Conn::read_settings

commit 668a7e4
Author: Anatoly Ikorsky <aikorsky@gmail.com>
Date:   Fri Aug 4 15:36:53 2023 +0300

    Do not read unnecessary settings in Conn::read_settings

commit ddee16e
Merge: e6bbf7c bf4fe8c
Author: Anatoly I <aikorsky@gmail.com>
Date:   Tue Apr 25 07:26:52 2023 -0700

    Merge pull request blackbeam#248 from cloneable/issue247-prio-queue-replacement

    Replace crate priority_queue with keyed_priority_queue

commit bf4fe8c
Author: Folke Behrens <folke@gmail.com>
Date:   Mon Apr 24 19:20:59 2023 +0200

    Replace crate priority_queue with keyed_priority_queue

    Fixes blackbeam#247

commit e6bbf7c
Author: Anatoly Ikorsky <aikorsky@gmail.com>
Date:   Sat Apr 22 12:44:54 2023 +0300

    Bump version

commit a9e2278
Author: Anatoly Ikorsky <aikorsky@gmail.com>
Date:   Sat Apr 22 12:44:44 2023 +0300

    Update README.md

commit c1c8081
Author: Anatoly Ikorsky <aikorsky@gmail.com>
Date:   Sat Apr 22 12:43:46 2023 +0300

    Remove mysql_common/derive from the set of enabled mysql_common features

commit 55fff99
Merge: 5843e91 485c7b7
Author: Anatoly I <aikorsky@gmail.com>
Date:   Sat Apr 22 02:35:27 2023 -0700

    Merge pull request blackbeam#246 from blackbeam/issue-244

    Use rust flate2 backend on default-rustls feature (see blackbeam#244)

commit 485c7b7
Author: Anatoly Ikorsky <aikorsky@gmail.com>
Date:   Thu Apr 20 20:43:00 2023 +0300

    Fix pool::test::should_reconnect

commit 48608a1
Author: Anatoly Ikorsky <aikorsky@gmail.com>
Date:   Thu Apr 20 20:42:15 2023 +0300

    Use rust flate2 backend on default-rustls feature (fix blackbeam#244)

commit 5843e91
Merge: 73dbb96 cd1ae04
Author: Anatoly I <aikorsky@gmail.com>
Date:   Thu Apr 20 10:17:49 2023 -0700

    Merge pull request blackbeam#245 from prisma/inline-reading-settings

    Inline ops that read settings

commit cd1ae04
Author: Miguel Fernández <fernandez@prisma.io>
Date:   Thu Apr 20 09:34:50 2023 +0200

    Inline ops that read settings (WasmEdge#2)

    Measures taken on 100 coldstart connections to a remote RDS mysql 5.7 in us-east-1, accessed from Spain. Units are ms.

    Before patch:

    Average: 222.01605959
    Standard deviation: 20.28249939282523

    After patch:

    Average: 152.8317912
    Standard deviation: 22.382571070107467

    Inlining queries make connections that require reading server settings run ~30% faster.

commit 73dbb96
Author: Anatoly Ikorsky <aikorsky@gmail.com>
Date:   Fri Apr 14 09:34:59 2023 +0300

    Add `Opts::setup` and `OptsBuilder::setup`

commit 7c6572d
Author: Anatoly Ikorsky <aikorsky@gmail.com>
Date:   Fri Apr 14 09:16:37 2023 +0300

    Add a way to opt-out of pooled connection reset

commit 32c6f2a
Author: Anatoly Ikorsky <aikorsky@gmail.com>
Date:   Thu Apr 13 14:18:07 2023 +0300

    Bump micro version

commit f23dca0
Author: Anatoly Ikorsky <aikorsky@gmail.com>
Date:   Thu Apr 13 13:40:41 2023 +0300

    recycler: check for closed pool in conn_return! macro

commit 8c4b72a
Author: Anatoly Ikorsky <aikorsky@gmail.com>
Date:   Thu Apr 13 09:59:42 2023 +0300

    recycler: assert that reset queue is exhausted on eof

commit 411a84a
Author: Anatoly Ikorsky <aikorsky@gmail.com>
Date:   Thu Apr 13 09:59:07 2023 +0300

    pool: Fix some connections not being properly reset

commit bbf24b0
Author: Anatoly Ikorsky <aikorsky@gmail.com>
Date:   Wed Apr 12 18:34:13 2023 +0300

    Bump dependencies

commit 3763e92
Author: Anatoly Ikorsky <aikorsky@gmail.com>
Date:   Wed Apr 12 17:32:40 2023 +0300

    Bump mysql_common to 0.30.1

commit bd6a503
Merge: 59e8c3c ec9a15b
Author: Anatoly I <aikorsky@gmail.com>
Date:   Wed Apr 12 07:23:55 2023 -0700

    Merge pull request blackbeam#242 from blackbeam/mysql-common-derive

    Prepare 0.32.0 release

commit ec9a15b
Author: Anatoly Ikorsky <aikorsky@gmail.com>
Date:   Wed Apr 12 15:32:18 2023 +0300

    Fix tests

commit 134cbf8
Author: Anatoly Ikorsky <aikorsky@gmail.com>
Date:   Wed Apr 12 15:09:36 2023 +0300

    Implement Conn::change_user

commit ad90c52
Author: Anatoly Ikorsky <aikorsky@gmail.com>
Date:   Sun Apr 9 18:56:11 2023 +0300

    Bump version

commit 2842af3
Author: Anatoly Ikorsky <aikorsky@gmail.com>
Date:   Sun Apr 9 18:54:44 2023 +0300

    Bump mysql_common to 0.30, add cleartext plugin support

commit 59e8c3c
Merge: f1afb7c 6ca8bec
Author: Anatoly I <aikorsky@gmail.com>
Date:   Mon Mar 13 07:58:14 2023 -0700

    Merge pull request blackbeam#238 from benesch/patch-1

    Update to lru v0.10.0

commit 6ca8bec
Author: Nikhil Benesch <nikhil.benesch@gmail.com>
Date:   Sat Mar 11 18:27:27 2023 -0500

    Update to lru v0.10.0

commit f1afb7c
Merge: 8323780 75ade0d
Author: Anatoly I <aikorsky@gmail.com>
Date:   Wed Feb 22 21:55:25 2023 -0800

    Merge pull request blackbeam#236 from blackbeam/capabilities-setup

    Capabilities setup

commit 75ade0d
Author: Anatoly Ikorsky <aikorsky@gmail.com>
Date:   Wed Feb 22 11:30:36 2023 +0300

    Rename writes_return_found_rows > client_found_rows. Add connection URL support

commit 5efd77e
Author: Julius de Bruijn <julius+github@nauk.io>
Date:   Tue Feb 21 17:37:39 2023 +0100

    Allow setting to return found rows when writing to the database

commit 8323780
Author: Anatoly Ikorsky <aikorsky@gmail.com>
Date:   Wed Feb 15 17:22:03 2023 +0300

    Bump micro version

commit 35fa6ab
Author: Anatoly Ikorsky <aikorsky@gmail.com>
Date:   Wed Feb 15 17:18:25 2023 +0300

    doc: Update `tracing` feature description

commit 287dd86
Merge: 043d81a 9effa91
Author: Anatoly I <aikorsky@gmail.com>
Date:   Wed Feb 15 04:03:37 2023 -0800

    Merge pull request blackbeam#230 from cloneable/issue223-record-errors-spans

    Record errors from routines in tracing spans

commit 9effa91
Author: Anatoly Ikorsky <aikorsky@gmail.com>
Date:   Tue Feb 14 21:47:19 2023 +0300

    Introduce instrument_result! macro

commit c851de7
Author: Folke Behrens <folke@gmail.com>
Date:   Sat Feb 11 23:00:25 2023 +0100

    Record errors from routines in tracing spans

    Updates blackbeam#223

commit 043d81a
Merge: ca61d55 72dded0
Author: Anatoly I <aikorsky@gmail.com>
Date:   Mon Feb 13 12:20:19 2023 -0800

    Merge pull request blackbeam#228 from cloneable/issue223-get_conn-and-conn-queries

    Don't emit INFO spans for administrative queries

commit 72dded0
Author: Anatoly Ikorsky <aikorsky@gmail.com>
Date:   Mon Feb 13 20:12:55 2023 +0300

    Move QueryRoutine tracing level to compile time

commit ca61d55
Merge: 0e8d22e 53d6adb
Author: Anatoly I <aikorsky@gmail.com>
Date:   Fri Feb 10 23:35:19 2023 -0800

    Merge pull request blackbeam#229 from cloneable/bufferpool-optimization

    Allow specifying an initial pooled buffer size

commit 53d6adb
Author: Folke Behrens <folke@gmail.com>
Date:   Thu Feb 9 22:45:19 2023 +0100

    Allow specifying an initial pooled buffer size

    Also move set_len(0) into put() and use Vec::shrink_to().

commit 0fd5853
Author: Folke Behrens <folke@gmail.com>
Date:   Wed Feb 8 20:57:45 2023 +0100

    Don't emit INFO spans for administrative queries

    This prevents internal queries like
    `SELECT @@max_allowed_packet` from showing up in user
    tracing unless tracing level TRACE is allowed.

commit 0e8d22e
Merge: 991069a 7917e84
Author: Anatoly I <aikorsky@gmail.com>
Date:   Thu Feb 2 02:06:34 2023 -0800

    Merge pull request blackbeam#226 from blackbeam/issue-225-ssl-query-params

    Introduce SSL-related query params (fix blackbeam#225)

commit 7917e84
Author: Anatoly Ikorsky <aikorsky@gmail.com>
Date:   Tue Jan 31 12:45:09 2023 +0300

    Update root docs

commit 94bdf23
Author: Anatoly Ikorsky <aikorsky@gmail.com>
Date:   Tue Jan 31 12:41:46 2023 +0300

    Document ssl-related URL parameters

commit 2b8f082
Author: Anatoly Ikorsky <aikorsky@gmail.com>
Date:   Tue Jan 31 12:24:25 2023 +0300

    opts: Add ssl-related query parameters

commit 991069a
Merge: fa7a5a7 0fdecd5
Author: Anatoly I <aikorsky@gmail.com>
Date:   Sat Jan 28 01:20:06 2023 -0800

    Merge pull request blackbeam#224 from cloneable/issue223-tracing-instrumentation

    Add support for tracing

commit 0fdecd5
Author: Folke Behrens <folke@gmail.com>
Date:   Thu Jan 26 18:22:30 2023 +0100

    Add support for tracing

Signed-off-by: csh <458761603@qq.com>
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