Commit 757e756
committed
MDEV-22850 Reduce buf_pool.page_hash latch contention
For reads, the buf_pool.page_hash is protected by buf_pool.mutex or by the hash_lock. There is no need to compute or acquire hash_lock if we are not modifying the buf_pool.page_hash. However, the buf_pool.page_hash latch must be held exclusively when changing buf_page_t::in_file(), or if we desire to prevent buf_page_t::can_relocate() or buf_page_t::buf_fix_count() from changing. rw_lock_lock_word_decr(): Add a comment that explains the polling logic. buf_page_t::set_state(): When in_file() is to be changed, assert that an exclusive buf_pool.page_hash latch is being held. Unfortunately we cannot assert this for set_state(BUF_BLOCK_REMOVE_HASH) because set_corrupt_id() may already have been called. buf_LRU_free_page(): Check buf_page_t::can_relocate() before aqcuiring the hash_lock. buf_block_t::initialise(): Initialize also page.buf_fix_count(). buf_page_create(): Initialize buf_fix_count while not holding any mutex or hash_lock. Acquire the hash_lock only for the duration of inserting the block to the buf_pool.page_hash. buf_LRU_old_init(), buf_LRU_add_block(), buf_page_t::belongs_to_unzip_LRU(): Do not assert buf_page_t::in_file(), because buf_page_create() will invoke buf_LRU_add_block() before acquiring hash_lock and buf_page_t::set_state(). buf_pool_t::validate(): Rely on the buf_pool.mutex and do not unnecessarily acquire any buf_pool.page_hash latches. buf_page_init_for_read(): Clarify that we must acquire the hash_lock upfront in order to prevent a race with buf_pool_t::watch_remove().1 parent 0af1b0b commit 757e756
File tree
5 files changed
+88
-25
lines changed- storage/innobase
- buf
- include
5 files changed
+88
-25
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3776 | 3776 | | |
3777 | 3777 | | |
3778 | 3778 | | |
3779 | | - | |
3780 | | - | |
3781 | | - | |
| 3779 | + | |
| 3780 | + | |
| 3781 | + | |
| 3782 | + | |
| 3783 | + | |
3782 | 3784 | | |
3783 | 3785 | | |
3784 | 3786 | | |
3785 | 3787 | | |
3786 | | - | |
3787 | | - | |
| 3788 | + | |
3788 | 3789 | | |
3789 | 3790 | | |
3790 | 3791 | | |
| |||
3803 | 3804 | | |
3804 | 3805 | | |
3805 | 3806 | | |
3806 | | - | |
| 3807 | + | |
3807 | 3808 | | |
3808 | | - | |
3809 | 3809 | | |
3810 | | - | |
3811 | 3810 | | |
3812 | 3811 | | |
3813 | 3812 | | |
| |||
3816 | 3815 | | |
3817 | 3816 | | |
3818 | 3817 | | |
3819 | | - | |
3820 | 3818 | | |
3821 | 3819 | | |
3822 | 3820 | | |
| |||
3846 | 3844 | | |
3847 | 3845 | | |
3848 | 3846 | | |
3849 | | - | |
| 3847 | + | |
| 3848 | + | |
| 3849 | + | |
| 3850 | + | |
| 3851 | + | |
3850 | 3852 | | |
3851 | 3853 | | |
3852 | | - | |
3853 | 3854 | | |
| 3855 | + | |
| 3856 | + | |
| 3857 | + | |
3854 | 3858 | | |
3855 | 3859 | | |
3856 | 3860 | | |
| |||
4401 | 4405 | | |
4402 | 4406 | | |
4403 | 4407 | | |
4404 | | - | |
4405 | 4408 | | |
4406 | 4409 | | |
4407 | 4410 | | |
| |||
4492 | 4495 | | |
4493 | 4496 | | |
4494 | 4497 | | |
4495 | | - | |
4496 | 4498 | | |
4497 | 4499 | | |
4498 | 4500 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
940 | 940 | | |
941 | 941 | | |
942 | 942 | | |
943 | | - | |
944 | 943 | | |
945 | 944 | | |
946 | 945 | | |
| |||
1066 | 1065 | | |
1067 | 1066 | | |
1068 | 1067 | | |
1069 | | - | |
1070 | 1068 | | |
1071 | 1069 | | |
1072 | 1070 | | |
| |||
1153 | 1151 | | |
1154 | 1152 | | |
1155 | 1153 | | |
| 1154 | + | |
| 1155 | + | |
| 1156 | + | |
| 1157 | + | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
1156 | 1162 | | |
1157 | 1163 | | |
1158 | 1164 | | |
1159 | | - | |
| 1165 | + | |
1160 | 1166 | | |
1161 | 1167 | | |
1162 | 1168 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
| 124 | + | |
| 125 | + | |
124 | 126 | | |
125 | 127 | | |
126 | 128 | | |
| |||
151 | 153 | | |
152 | 154 | | |
153 | 155 | | |
154 | | - | |
155 | 156 | | |
| 157 | + | |
156 | 158 | | |
157 | 159 | | |
158 | 160 | | |
| |||
202 | 204 | | |
203 | 205 | | |
204 | 206 | | |
205 | | - | |
206 | | - | |
| 207 | + | |
| 208 | + | |
207 | 209 | | |
208 | 210 | | |
209 | 211 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
995 | 995 | | |
996 | 996 | | |
997 | 997 | | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
998 | 1006 | | |
999 | 1007 | | |
1000 | 1008 | | |
| |||
1010 | 1018 | | |
1011 | 1019 | | |
1012 | 1020 | | |
1013 | | - | |
1014 | | - | |
| 1021 | + | |
1015 | 1022 | | |
1016 | 1023 | | |
1017 | 1024 | | |
| |||
1277 | 1284 | | |
1278 | 1285 | | |
1279 | 1286 | | |
1280 | | - | |
1281 | | - | |
1282 | | - | |
| 1287 | + | |
| 1288 | + | |
| 1289 | + | |
| 1290 | + | |
1283 | 1291 | | |
1284 | 1292 | | |
1285 | 1293 | | |
| |||
2134 | 2142 | | |
2135 | 2143 | | |
2136 | 2144 | | |
| 2145 | + | |
| 2146 | + | |
| 2147 | + | |
| 2148 | + | |
| 2149 | + | |
| 2150 | + | |
| 2151 | + | |
| 2152 | + | |
| 2153 | + | |
| 2154 | + | |
| 2155 | + | |
| 2156 | + | |
| 2157 | + | |
| 2158 | + | |
| 2159 | + | |
| 2160 | + | |
| 2161 | + | |
| 2162 | + | |
| 2163 | + | |
| 2164 | + | |
| 2165 | + | |
| 2166 | + | |
| 2167 | + | |
2137 | 2168 | | |
2138 | 2169 | | |
2139 | 2170 | | |
| |||
2212 | 2243 | | |
2213 | 2244 | | |
2214 | 2245 | | |
2215 | | - | |
2216 | 2246 | | |
2217 | 2247 | | |
2218 | 2248 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
220 | 220 | | |
221 | 221 | | |
222 | 222 | | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
223 | 243 | | |
| 244 | + | |
224 | 245 | | |
| 246 | + | |
| 247 | + | |
225 | 248 | | |
226 | 249 | | |
227 | 250 | | |
| |||
0 commit comments