forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commite8d029a
committed
Do unlocked prechecks in bufmgr.c loops that scan the whole buffer pool.
DropRelFileNodeBuffers, DropDatabaseBuffers, FlushRelationBuffers, andFlushDatabaseBuffers have to scan the whole shared_buffers pool becausewe have no index structure that would find the target buffers any moreefficiently than that. This gets expensive with large NBuffers. We canshave some cycles from these loops by prechecking to see if the currentbuffer is interesting before we acquire the buffer header lock.Ordinarily such a test would be unsafe, but in these cases it should besafe because we are already assuming that the caller holds a lock thatprevents any new target pages from being loaded into the buffer poolconcurrently. Therefore, no buffer tag should be changing to a value ofinterest, only away from a value of interest. So a false negative matchis impossible, while a false positive is safe because we'll recheck afteracquiring the buffer lock. Initial testing says that this speeds theseloops by a factor of 2X to 3X on common Intel hardware.Patch for DropRelFileNodeBuffers by Jeff Janes (based on an idea ofHeikki's); extended to the remaining sequential scans by Tom Lane1 parent2c8a4e9 commite8d029a
1 file changed
+45
-2
lines changedLines changed: 45 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2048 | 2048 |
| |
2049 | 2049 |
| |
2050 | 2050 |
| |
| 2051 | + | |
2051 | 2052 |
| |
2052 | 2053 |
| |
2053 | 2054 |
| |
| |||
2059 | 2060 |
| |
2060 | 2061 |
| |
2061 | 2062 |
| |
| 2063 | + | |
| 2064 | + | |
| 2065 | + | |
| 2066 | + | |
| 2067 | + | |
| 2068 | + | |
| 2069 | + | |
| 2070 | + | |
| 2071 | + | |
| 2072 | + | |
| 2073 | + | |
| 2074 | + | |
| 2075 | + | |
| 2076 | + | |
| 2077 | + | |
| 2078 | + | |
| 2079 | + | |
| 2080 | + | |
| 2081 | + | |
2062 | 2082 |
| |
2063 | 2083 |
| |
2064 | 2084 |
| |
| |||
2084 | 2104 |
| |
2085 | 2105 |
| |
2086 | 2106 |
| |
2087 |
| - | |
2088 | 2107 |
| |
2089 | 2108 |
| |
2090 | 2109 |
| |
| |||
2093 | 2112 |
| |
2094 | 2113 |
| |
2095 | 2114 |
| |
2096 |
| - | |
| 2115 | + | |
| 2116 | + | |
| 2117 | + | |
| 2118 | + | |
| 2119 | + | |
| 2120 | + | |
| 2121 | + | |
| 2122 | + | |
| 2123 | + | |
2097 | 2124 |
| |
2098 | 2125 |
| |
2099 | 2126 |
| |
| |||
2220 | 2247 |
| |
2221 | 2248 |
| |
2222 | 2249 |
| |
| 2250 | + | |
| 2251 | + | |
| 2252 | + | |
| 2253 | + | |
| 2254 | + | |
| 2255 | + | |
| 2256 | + | |
| 2257 | + | |
2223 | 2258 |
| |
2224 | 2259 |
| |
2225 | 2260 |
| |
| |||
2262 | 2297 |
| |
2263 | 2298 |
| |
2264 | 2299 |
| |
| 2300 | + | |
| 2301 | + | |
| 2302 | + | |
| 2303 | + | |
| 2304 | + | |
| 2305 | + | |
| 2306 | + | |
| 2307 | + | |
2265 | 2308 |
| |
2266 | 2309 |
| |
2267 | 2310 |
| |
|
0 commit comments
Comments
(0)