Commit a7c0d28
committed
reduce allocations when binding string/time args
This commit reduces the number of allocations required to bind args by
eliminating string to byte slice conversions for string and time.Time
types and by only checking for bind parameters if any of the
driver.NamedValue args are named. It also changes bind to only reset the
sqlite3 statement when necessary - previously the statement was always
reset even on first use (this yields a 3-4% performance boost).
goos: darwin
goarch: arm64
pkg: github.com/mattn/go-sqlite3
cpu: Apple M4 Pro
│ y1.txt │ y2.txt │
│ sec/op │ sec/op vs base │
Suite/BenchmarkQuery-14 2.080µ ± 3% 1.995µ ± 0% -4.13% (p=0.000 n=10)
Suite/BenchmarkParams-14 2.282µ ± 1% 2.181µ ± 2% -4.43% (p=0.000 n=10)
Suite/BenchmarkStmt-14 1.537µ ± 1% 1.489µ ± 1% -3.16% (p=0.000 n=10)
geomean 1.939µ 1.864µ -3.91%
│ y1.txt │ y2.txt │
│ B/op │ B/op vs base │
Suite/BenchmarkQuery-14 688.0 ± 0% 688.0 ± 0% ~ (p=1.000 n=10) ¹
Suite/BenchmarkParams-14 1104.0 ± 0% 1000.0 ± 0% -9.42% (p=0.000 n=10)
Suite/BenchmarkStmt-14 920.0 ± 0% 816.0 ± 0% -11.30% (p=0.000 n=10)
geomean 887.4 824.9 -7.04%
¹ all samples are equal
│ y1.txt │ y2.txt │
│ allocs/op │ allocs/op vs base │
Suite/BenchmarkQuery-14 23.00 ± 0% 23.00 ± 0% ~ (p=1.000 n=10) ¹
Suite/BenchmarkParams-14 27.00 ± 0% 25.00 ± 0% -7.41% (p=0.000 n=10)
Suite/BenchmarkStmt-14 25.00 ± 0% 23.00 ± 0% -8.00% (p=0.000 n=10)
geomean 24.95 23.65 -5.20%
¹ all samples are equal1 parent 294c2ce commit a7c0d28
3 files changed
+128
-19
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
382 | 382 | | |
383 | 383 | | |
384 | 384 | | |
| 385 | + | |
385 | 386 | | |
386 | 387 | | |
387 | 388 | | |
| |||
1921 | 1922 | | |
1922 | 1923 | | |
1923 | 1924 | | |
| 1925 | + | |
| 1926 | + | |
| 1927 | + | |
| 1928 | + | |
| 1929 | + | |
| 1930 | + | |
| 1931 | + | |
| 1932 | + | |
| 1933 | + | |
1924 | 1934 | | |
1925 | | - | |
1926 | | - | |
1927 | | - | |
| 1935 | + | |
| 1936 | + | |
| 1937 | + | |
| 1938 | + | |
| 1939 | + | |
| 1940 | + | |
| 1941 | + | |
| 1942 | + | |
| 1943 | + | |
| 1944 | + | |
| 1945 | + | |
| 1946 | + | |
| 1947 | + | |
| 1948 | + | |
| 1949 | + | |
| 1950 | + | |
| 1951 | + | |
| 1952 | + | |
| 1953 | + | |
| 1954 | + | |
| 1955 | + | |
| 1956 | + | |
| 1957 | + | |
| 1958 | + | |
| 1959 | + | |
| 1960 | + | |
| 1961 | + | |
| 1962 | + | |
| 1963 | + | |
| 1964 | + | |
| 1965 | + | |
| 1966 | + | |
| 1967 | + | |
| 1968 | + | |
| 1969 | + | |
| 1970 | + | |
| 1971 | + | |
| 1972 | + | |
| 1973 | + | |
| 1974 | + | |
| 1975 | + | |
| 1976 | + | |
| 1977 | + | |
| 1978 | + | |
| 1979 | + | |
| 1980 | + | |
| 1981 | + | |
| 1982 | + | |
| 1983 | + | |
| 1984 | + | |
| 1985 | + | |
| 1986 | + | |
1928 | 1987 | | |
| 1988 | + | |
| 1989 | + | |
| 1990 | + | |
| 1991 | + | |
| 1992 | + | |
| 1993 | + | |
| 1994 | + | |
| 1995 | + | |
| 1996 | + | |
| 1997 | + | |
| 1998 | + | |
| 1999 | + | |
1929 | 2000 | | |
1930 | 2001 | | |
1931 | | - | |
1932 | 2002 | | |
1933 | 2003 | | |
1934 | 2004 | | |
1935 | | - | |
1936 | | - | |
1937 | | - | |
1938 | | - | |
| 2005 | + | |
| 2006 | + | |
| 2007 | + | |
| 2008 | + | |
| 2009 | + | |
1939 | 2010 | | |
1940 | 2011 | | |
1941 | 2012 | | |
1942 | 2013 | | |
1943 | 2014 | | |
| 2015 | + | |
1944 | 2016 | | |
1945 | 2017 | | |
1946 | 2018 | | |
| |||
1951 | 2023 | | |
1952 | 2024 | | |
1953 | 2025 | | |
1954 | | - | |
1955 | | - | |
1956 | | - | |
1957 | | - | |
1958 | | - | |
1959 | | - | |
| 2026 | + | |
| 2027 | + | |
1960 | 2028 | | |
1961 | 2029 | | |
1962 | 2030 | | |
| 2031 | + | |
1963 | 2032 | | |
1964 | | - | |
1965 | | - | |
1966 | | - | |
| 2033 | + | |
1967 | 2034 | | |
| 2035 | + | |
1968 | 2036 | | |
1969 | 2037 | | |
1970 | 2038 | | |
| |||
1978 | 2046 | | |
1979 | 2047 | | |
1980 | 2048 | | |
1981 | | - | |
1982 | | - | |
| 2049 | + | |
| 2050 | + | |
| 2051 | + | |
1983 | 2052 | | |
1984 | 2053 | | |
1985 | 2054 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
0 commit comments