Commit 0bf8475
authored
Optimize init pool: Reduce VM/Pod API calls (#577)
* pool/initMaps: Add pagination to getManagedNamespaces to reduce memory usage
Introduce pagination with 500 namespaces per page when gathering
managed namespaces during initialization.
This prevents loading all namespaces into memory at once in clusters
with thousands of namespaces.
Signed-off-by: Ram Lavi <ralavi@redhat.com>
* Refactor getManagedNamespaces to return a set
Change getManagedNamespaces to return map[string]struct{} instead of
[]string, making it more idiomatic Go.
This set will be used in future commits to easily check whether a ns is
managed or not.
Signed-off-by: Ram Lavi <ralavi@redhat.com>
* Optimize VM initialization with cluster-wide listing
Currently during VM pool map init, only managed namespaces are called,
but for each we do an API call, which can be slow in clusters with
large number of namespaces.
Replace per-namespace VM listing with cluster-wide listing and in-memory
filtering, while keeping the pagination to avoid over using the memory.
This dramatically reduces API calls during initialization.
The Trade-off is fetching VMs from unmanaged namespaces then filters
them out, but the network overhead is negligible compared to the latency
savings from fewer round trips.
Signed-off-by: Ram Lavi <ralavi@redhat.com>
* Increase pagination limit to 500 for VM initialization
Increase the pagination limit from 100 to 500 when fetching VMs during
initialization.
This further reduces API calls by fetching larger batches.
Signed-off-by: Ram Lavi <ralavi@redhat.com>
* Optimize Pod initialization with cluster-wide listing
Currently during Pod pool map init, only managed namespaces are called,
but for each we do an API call, which can be slow in clusters with
large number of namespaces.
Replace per-namespace Pod listing with cluster-wide listing and
in-memory filtering, while keeping the pagination to avoid over using
the memory.
This dramatically reduces API calls during initialization.
The Trade-off is fetching Pods from unmanaged namespaces then filters
them out, but the network overhead is negligible compared to the latency
savings from fewer round trips.
Signed-off-by: Ram Lavi <ralavi@redhat.com>
* Increase pagination limit to 500 for Pod initialization
Increase the pagination limit from 100 to 500 when fetching Pods during
initialization.
This further reduces API calls by fetching larger batches.
Signed-off-by: Ram Lavi <ralavi@redhat.com>
---------
Signed-off-by: Ram Lavi <ralavi@redhat.com>1 parent d6411fd commit 0bf8475
3 files changed
+87
-62
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
193 | 193 | | |
194 | 194 | | |
195 | 195 | | |
196 | | - | |
| 196 | + | |
197 | 197 | | |
198 | 198 | | |
199 | 199 | | |
| |||
205 | 205 | | |
206 | 206 | | |
207 | 207 | | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | 208 | | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
222 | 212 | | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
228 | 217 | | |
229 | 218 | | |
230 | | - | |
| 219 | + | |
231 | 220 | | |
232 | 221 | | |
233 | | - | |
234 | | - | |
235 | | - | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
236 | 237 | | |
237 | 238 | | |
238 | 239 | | |
239 | | - | |
240 | 240 | | |
241 | 241 | | |
242 | 242 | | |
243 | 243 | | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
244 | 250 | | |
245 | 251 | | |
246 | 252 | | |
247 | 253 | | |
248 | 254 | | |
249 | | - | |
| 255 | + | |
250 | 256 | | |
251 | 257 | | |
252 | 258 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
149 | | - | |
| 149 | + | |
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
| |||
159 | 159 | | |
160 | 160 | | |
161 | 161 | | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
167 | 165 | | |
168 | | - | |
169 | | - | |
170 | | - | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
171 | 172 | | |
172 | | - | |
173 | | - | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
174 | 185 | | |
175 | | - | |
176 | | - | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
177 | 190 | | |
178 | 191 | | |
179 | 192 | | |
180 | | - | |
| 193 | + | |
181 | 194 | | |
182 | 195 | | |
183 | 196 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
309 | 309 | | |
310 | 310 | | |
311 | 311 | | |
312 | | - | |
| 312 | + | |
313 | 313 | | |
314 | 314 | | |
315 | 315 | | |
| |||
321 | 321 | | |
322 | 322 | | |
323 | 323 | | |
324 | | - | |
325 | | - | |
326 | | - | |
327 | | - | |
328 | | - | |
329 | | - | |
330 | | - | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | | - | |
337 | 324 | | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
338 | 328 | | |
339 | 329 | | |
340 | 330 | | |
341 | | - | |
342 | | - | |
343 | | - | |
| 331 | + | |
| 332 | + | |
344 | 333 | | |
345 | 334 | | |
346 | | - | |
| 335 | + | |
347 | 336 | | |
348 | 337 | | |
349 | | - | |
350 | | - | |
351 | | - | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
352 | 353 | | |
353 | 354 | | |
354 | 355 | | |
355 | | - | |
356 | 356 | | |
357 | 357 | | |
358 | 358 | | |
359 | 359 | | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
360 | 366 | | |
361 | 367 | | |
362 | 368 | | |
363 | 369 | | |
364 | 370 | | |
365 | 371 | | |
366 | | - | |
| 372 | + | |
367 | 373 | | |
368 | 374 | | |
369 | 375 | | |
| |||
0 commit comments