Commit 48fd7eb
Revert "bcache: remove heap-related macros and switch to generic min_heap"
This reverts commit 866898e.
The generic bottom-up min_heap implementation causes performance
regression in invalidate_buckets_lru(), a hot path in bcache. Before the
cache is fully populated, new_bucket_prio() often returns zero, leading to
many equal comparisons. In such cases, bottom-up sift_down performs up to
2 * log2(n) comparisons, while the original top-down approach completes
with just O() comparisons, resulting in a measurable performance gap.
The performance degradation is further worsened by the non-inlined
min_heap API functions introduced in commit 92a8b22 ("lib/min_heap:
introduce non-inline versions of min heap API functions"), adding function
call overhead to this critical path.
As reported by Robert, bcache now suffers from latency spikes, with P100
(max) latency increasing from 600 ms to 2.4 seconds every 5 minutes.
These regressions degrade bcache's effectiveness as a low-latency cache
layer and lead to frequent timeouts and application stalls in production
environments.
This revert aims to restore bcache's original low-latency behavior.
Link: https://lore.kernel.org/lkml/CAJhEC05+0S69z+3+FB2Cd0hD+pCRyWTKLEOsc8BOmH73p1m+KQ@mail.gmail.com
Link: https://lkml.kernel.org/r/[email protected]
Fixes: 866898e ("bcache: remove heap-related macros and switch to generic min_heap")
Fixes: 92a8b22 ("lib/min_heap: introduce non-inline versions of min heap API functions")
Signed-off-by: Kuan-Wei Chiu <[email protected]>
Reported-by: Robert Pang <[email protected]>
Closes: https://lore.kernel.org/linux-bcache/CAJhEC06F_AtrPgw2-7CvCqZgeStgCtitbD-ryuPpXQA-JG5XXw@mail.gmail.com
Acked-by: Coly Li <[email protected]>
Cc: Ching-Chun (Jim) Huang <[email protected]>
Cc: Kent Overstreet <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>1 parent 845f1f2 commit 48fd7eb
11 files changed
+217
-263
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
164 | 164 | | |
165 | 165 | | |
166 | 166 | | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
195 | 173 | | |
196 | | - | |
197 | | - | |
| 174 | + | |
| 175 | + | |
198 | 176 | | |
199 | 177 | | |
200 | 178 | | |
201 | 179 | | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
| 180 | + | |
210 | 181 | | |
211 | | - | |
| 182 | + | |
212 | 183 | | |
213 | 184 | | |
214 | 185 | | |
215 | 186 | | |
216 | 187 | | |
217 | | - | |
218 | | - | |
219 | | - | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
220 | 191 | | |
221 | | - | |
| 192 | + | |
222 | 193 | | |
223 | 194 | | |
224 | 195 | | |
225 | | - | |
| 196 | + | |
| 197 | + | |
226 | 198 | | |
227 | 199 | | |
228 | | - | |
| 200 | + | |
229 | 201 | | |
230 | 202 | | |
231 | 203 | | |
| |||
234 | 206 | | |
235 | 207 | | |
236 | 208 | | |
237 | | - | |
238 | | - | |
239 | 209 | | |
240 | 210 | | |
241 | 211 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
458 | 458 | | |
459 | 459 | | |
460 | 460 | | |
461 | | - | |
| 461 | + | |
462 | 462 | | |
463 | 463 | | |
464 | 464 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
58 | 58 | | |
59 | 59 | | |
60 | | - | |
61 | | - | |
62 | 60 | | |
63 | 61 | | |
64 | 62 | | |
| |||
69 | 67 | | |
70 | 68 | | |
71 | 69 | | |
72 | | - | |
| 70 | + | |
73 | 71 | | |
74 | 72 | | |
75 | | - | |
76 | | - | |
77 | 73 | | |
78 | 74 | | |
79 | 75 | | |
| |||
114 | 110 | | |
115 | 111 | | |
116 | 112 | | |
117 | | - | |
| 113 | + | |
118 | 114 | | |
119 | | - | |
| 115 | + | |
120 | 116 | | |
121 | 117 | | |
122 | 118 | | |
| |||
883 | 879 | | |
884 | 880 | | |
885 | 881 | | |
886 | | - | |
| 882 | + | |
887 | 883 | | |
888 | 884 | | |
889 | 885 | | |
890 | 886 | | |
891 | 887 | | |
892 | | - | |
893 | | - | |
894 | 888 | | |
895 | 889 | | |
896 | 890 | | |
| |||
901 | 895 | | |
902 | 896 | | |
903 | 897 | | |
904 | | - | |
| 898 | + | |
905 | 899 | | |
906 | | - | |
| 900 | + | |
907 | 901 | | |
908 | 902 | | |
909 | 903 | | |
| |||
1083 | 1077 | | |
1084 | 1078 | | |
1085 | 1079 | | |
1086 | | - | |
1087 | | - | |
1088 | | - | |
1089 | | - | |
1090 | | - | |
1091 | | - | |
1092 | | - | |
1093 | | - | |
1094 | | - | |
| 1080 | + | |
| 1081 | + | |
1095 | 1082 | | |
1096 | | - | |
| 1083 | + | |
| 1084 | + | |
1097 | 1085 | | |
1098 | | - | |
1099 | | - | |
1100 | | - | |
1101 | | - | |
| 1086 | + | |
1102 | 1087 | | |
1103 | 1088 | | |
1104 | 1089 | | |
1105 | 1090 | | |
1106 | | - | |
| 1091 | + | |
1107 | 1092 | | |
1108 | 1093 | | |
1109 | 1094 | | |
1110 | 1095 | | |
1111 | 1096 | | |
1112 | | - | |
1113 | | - | |
1114 | | - | |
1115 | | - | |
1116 | | - | |
1117 | 1097 | | |
1118 | | - | |
1119 | | - | |
1120 | | - | |
1121 | | - | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
1122 | 1101 | | |
1123 | 1102 | | |
1124 | | - | |
1125 | | - | |
1126 | | - | |
1127 | | - | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
1128 | 1107 | | |
1129 | 1108 | | |
1130 | 1109 | | |
1131 | | - | |
1132 | | - | |
| 1110 | + | |
| 1111 | + | |
1133 | 1112 | | |
1134 | 1113 | | |
1135 | | - | |
| 1114 | + | |
1136 | 1115 | | |
1137 | 1116 | | |
1138 | 1117 | | |
1139 | 1118 | | |
1140 | | - | |
| 1119 | + | |
1141 | 1120 | | |
1142 | 1121 | | |
1143 | 1122 | | |
1144 | 1123 | | |
1145 | 1124 | | |
1146 | | - | |
1147 | | - | |
| 1125 | + | |
| 1126 | + | |
1148 | 1127 | | |
1149 | 1128 | | |
1150 | | - | |
| 1129 | + | |
1151 | 1130 | | |
1152 | 1131 | | |
1153 | 1132 | | |
1154 | | - | |
| 1133 | + | |
1155 | 1134 | | |
1156 | 1135 | | |
1157 | 1136 | | |
1158 | | - | |
1159 | | - | |
1160 | | - | |
1161 | | - | |
1162 | 1137 | | |
1163 | 1138 | | |
1164 | 1139 | | |
1165 | 1140 | | |
1166 | | - | |
1167 | | - | |
| 1141 | + | |
| 1142 | + | |
1168 | 1143 | | |
1169 | | - | |
| 1144 | + | |
1170 | 1145 | | |
1171 | | - | |
| 1146 | + | |
1172 | 1147 | | |
1173 | 1148 | | |
1174 | | - | |
1175 | | - | |
1176 | | - | |
1177 | | - | |
1178 | | - | |
1179 | | - | |
| 1149 | + | |
| 1150 | + | |
1180 | 1151 | | |
1181 | | - | |
| 1152 | + | |
1182 | 1153 | | |
1183 | 1154 | | |
1184 | 1155 | | |
1185 | 1156 | | |
1186 | 1157 | | |
1187 | 1158 | | |
1188 | 1159 | | |
1189 | | - | |
| 1160 | + | |
1190 | 1161 | | |
1191 | 1162 | | |
1192 | 1163 | | |
| |||
1224 | 1195 | | |
1225 | 1196 | | |
1226 | 1197 | | |
| 1198 | + | |
1227 | 1199 | | |
1228 | 1200 | | |
1229 | 1201 | | |
1230 | 1202 | | |
1231 | 1203 | | |
1232 | | - | |
1233 | | - | |
1234 | | - | |
1235 | | - | |
1236 | 1204 | | |
1237 | 1205 | | |
1238 | | - | |
| 1206 | + | |
| 1207 | + | |
1239 | 1208 | | |
1240 | 1209 | | |
1241 | 1210 | | |
| |||
1324 | 1293 | | |
1325 | 1294 | | |
1326 | 1295 | | |
1327 | | - | |
| 1296 | + | |
1328 | 1297 | | |
1329 | 1298 | | |
1330 | | - | |
1331 | | - | |
| 1299 | + | |
1332 | 1300 | | |
1333 | 1301 | | |
1334 | 1302 | | |
| |||
1339 | 1307 | | |
1340 | 1308 | | |
1341 | 1309 | | |
1342 | | - | |
| 1310 | + | |
1343 | 1311 | | |
1344 | 1312 | | |
1345 | 1313 | | |
| |||
1355 | 1323 | | |
1356 | 1324 | | |
1357 | 1325 | | |
1358 | | - | |
1359 | | - | |
1360 | | - | |
| 1326 | + | |
1361 | 1327 | | |
1362 | | - | |
| 1328 | + | |
1363 | 1329 | | |
1364 | | - | |
| 1330 | + | |
1365 | 1331 | | |
1366 | 1332 | | |
1367 | 1333 | | |
| |||
0 commit comments