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

database/sql: cherry-pick a couple 1.23 fixes #87

Open
bradfitz opened this issue Apr 3, 2024 · 0 comments
Open

database/sql: cherry-pick a couple 1.23 fixes #87

bradfitz opened this issue Apr 3, 2024 · 0 comments

Comments

@bradfitz
Copy link
Member

bradfitz commented Apr 3, 2024

commit e39af550f8ea57504510dc5d5fa70ba934f16fa0
Author: apocelipes <seve3r@outlook.com>
Date:   Wed Mar 20 05:33:46 2024 +0000

    database/sql: fix memory leaks in Stmt.removeClosedStmtLocked
    
    Zero out elements before shrinking the slice to avoid memory leaks.
    
    Fixes #66410
    
    Change-Id: I8f64c21455761f7f7c8b6fee0b6450b98f691d91
    GitHub-Last-Rev: b15586e801199b9674f5bfcb12a848a55f15a80b
    GitHub-Pull-Request: golang/go#66419
    Reviewed-on: https://go-review.googlesource.com/c/go/+/572956
    TryBot-Result: Gopher Robot <gobot@golang.org>
    LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
    Reviewed-by: David Chase <drchase@google.com>
    Reviewed-by: Keith Randall <khr@google.com>
    Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
    Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>

and

commit 190d0d3e69b113bea0b6b604ba2f0beb62c08741
Author: Brad Fitzpatrick <bradfitz@golang.org>
Date:   Sat Mar 16 18:29:06 2024 -0700

    database/sql: optimize connection request pool
    
    This replaces a map used as a set with a slice.
    
    We were using a surprising amount of CPU in this code, making mapiters
    to pull out a random element of the map. Instead, just rand.IntN to pick
    a random element of the slice.
    
    It also adds a benchmark:
    
                         │    before    │                after                │
                         │    sec/op    │   sec/op     vs base                │
        ConnRequestSet-8   1818.0n ± 0%   452.4n ± 0%  -75.12% (p=0.000 n=10)
    
    (whether random is a good policy is a bigger question, but this
     optimizes the current policy without changing behavior)
    
    Updates #66361
    
    Change-Id: I3d456a819cc720c2d18e1befffd2657e5f50f1e7
    Reviewed-on: https://go-review.googlesource.com/c/go/+/572119
    Reviewed-by: Cherry Mui <cherryyz@google.com>
    Reviewed-by: Ian Lance Taylor <iant@google.com>
    Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
    Reviewed-by: David Chase <drchase@google.com>
    LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
    Auto-Submit: Brad Fitzpatrick <bradfitz@golang.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant