Commit 6bf0e58
authored
fix: bound policy ancestors on the fly to avoid O(N^2) translation latency (#9558)
* fix: bound policy ancestors on the fly to avoid O(N^2) translation latency
When many resources reference the same target, a policy's status.Ancestors list
could grow without bound during translation. SetConditionForPolicyAncestor scans
the existing ancestors on every call, so building a status with N ancestors was
O(N^2); for a BackendTLSPolicy shared by e.g. 10k EnvoyExtensionPolicies this
pushed translation time to ~1h.
Cap status.Ancestors at maxPolicyAncestors+1 (17) as entries are added:
SetConditionForPolicyAncestor evicts the lowest-priority ancestor once the list
exceeds the soft cap, keeping every insert O(1) and the total O(N). The single
slot above the CRD limit lets the post-processing TruncatePolicyAncestors still
detect overflow, cut to 16, and stamp the Aggregated condition.
Note: because eviction happens as ancestors are added, before an ancestor's rank
is necessarily final, a policy with more than 16 ancestors that later marks a
truncated ancestor Overridden shows only the Overridden condition on it - the
redundant Accepted condition is dropped. This affects only truncated statuses.
Fixes #9539
Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
* update release note
Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
---------
Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>1 parent eda050e commit 6bf0e58
6 files changed
Lines changed: 123 additions & 41 deletions
File tree
- internal/gatewayapi
- status
- testdata
- release-notes/current/performance_improvements
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
30 | 45 | | |
31 | 46 | | |
32 | 47 | | |
| |||
166 | 181 | | |
167 | 182 | | |
168 | 183 | | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
169 | 210 | | |
170 | 211 | | |
171 | 212 | | |
| |||
243 | 284 | | |
244 | 285 | | |
245 | 286 | | |
246 | | - | |
| 287 | + | |
247 | 288 | | |
248 | 289 | | |
249 | 290 | | |
250 | | - | |
251 | | - | |
| 291 | + | |
| 292 | + | |
252 | 293 | | |
253 | 294 | | |
254 | | - | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | | - | |
259 | | - | |
260 | | - | |
261 | | - | |
262 | | - | |
263 | | - | |
264 | | - | |
265 | | - | |
266 | | - | |
267 | | - | |
268 | | - | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
| 295 | + | |
275 | 296 | | |
276 | 297 | | |
277 | 298 | | |
278 | 299 | | |
279 | | - | |
| 300 | + | |
280 | 301 | | |
281 | | - | |
| 302 | + | |
282 | 303 | | |
283 | 304 | | |
284 | 305 | | |
| |||
288 | 309 | | |
289 | 310 | | |
290 | 311 | | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
291 | 337 | | |
292 | 338 | | |
293 | 339 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
19 | 69 | | |
20 | 70 | | |
21 | 71 | | |
| |||
Lines changed: 0 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | 23 | | |
29 | 24 | | |
30 | 25 | | |
| |||
Lines changed: 0 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | 23 | | |
29 | 24 | | |
30 | 25 | | |
| |||
Lines changed: 0 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1729 | 1729 | | |
1730 | 1730 | | |
1731 | 1731 | | |
1732 | | - | |
1733 | | - | |
1734 | | - | |
1735 | | - | |
1736 | | - | |
1737 | 1732 | | |
1738 | 1733 | | |
1739 | 1734 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
0 commit comments