go
go copied to clipboard
database/sql: cherry-pick a couple 1.23 fixes
commit e39af550f8ea57504510dc5d5fa70ba934f16fa0
Author: apocelipes <[email protected]>
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 <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: David Chase <[email protected]>
Reviewed-by: Keith Randall <[email protected]>
Reviewed-by: Emmanuel Odeke <[email protected]>
Run-TryBot: Emmanuel Odeke <[email protected]>
and
commit 190d0d3e69b113bea0b6b604ba2f0beb62c08741
Author: Brad Fitzpatrick <[email protected]>
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 <[email protected]>
Reviewed-by: Ian Lance Taylor <[email protected]>
Reviewed-by: Emmanuel Odeke <[email protected]>
Reviewed-by: David Chase <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
Auto-Submit: Brad Fitzpatrick <[email protected]>