Skip to content

Commit 064c8dc

Browse files
committed
fix: convert concurrency and cache size calculations to integers
- wrap multiplication results with Math.round() for proper integer values - prevents floating point concurrency settings like 22.5 or 7.5 - ensures cache size calculations also return integers - addresses Copilot's code review recommendation
1 parent afba36e commit 064c8dc

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

packages/indexer-agent/src/performance-config.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -247,29 +247,29 @@ export function getOptimizedConfig(): PerformanceConfig {
247247
if (cpuCount >= 8) {
248248
config.allocationConcurrency = Math.min(
249249
30,
250-
config.allocationConcurrency * 1.5,
250+
Math.round(config.allocationConcurrency * 1.5),
251251
)
252252
config.deploymentConcurrency = Math.min(
253253
25,
254-
config.deploymentConcurrency * 1.5,
254+
Math.round(config.deploymentConcurrency * 1.5),
255255
)
256256
} else if (cpuCount <= 2) {
257257
config.allocationConcurrency = Math.max(
258258
5,
259-
config.allocationConcurrency * 0.5,
259+
Math.round(config.allocationConcurrency * 0.5),
260260
)
261261
config.deploymentConcurrency = Math.max(
262262
5,
263-
config.deploymentConcurrency * 0.5,
263+
Math.round(config.deploymentConcurrency * 0.5),
264264
)
265265
}
266266

267267
// Adjust cache size based on available memory
268268
const memoryGB = totalMemory / (1024 * 1024 * 1024)
269269
if (memoryGB >= 16) {
270-
config.cacheMaxSize = Math.min(5000, config.cacheMaxSize * 2)
270+
config.cacheMaxSize = Math.min(5000, Math.round(config.cacheMaxSize * 2))
271271
} else if (memoryGB <= 4) {
272-
config.cacheMaxSize = Math.max(500, config.cacheMaxSize * 0.5)
272+
config.cacheMaxSize = Math.max(500, Math.round(config.cacheMaxSize * 0.5))
273273
}
274274

275275
return config

0 commit comments

Comments
 (0)