Skip to content

Commit 613d34f

Browse files
committed
Merge branches 'feature/indexer-agent-performance-optimizations' and 'feature/indexer-agent-performance-optimizations' of github.com:graphprotocol/indexer into feature/indexer-agent-performance-optimizations
2 parents 4fbec85 + fa252c1 commit 613d34f

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

packages/indexer-agent/src/agent-optimized.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -467,10 +467,11 @@ export class Agent {
467467
},
468468
)
469469

470-
const deploymentMap: NetworkMapped<SubgraphDeployment[]> = {}
471-
for (const result of Object.values(networkDeployments)) {
472-
deploymentMap[result.networkId] = result.deployments
473-
}
470+
const deploymentMap: NetworkMapped<SubgraphDeployment[]> = Object.fromEntries(
471+
Object.values(networkDeployments).map(
472+
(result) => [result.networkId, result.deployments]
473+
)
474+
)
474475
return deploymentMap
475476
} else {
476477
// Fallback to sequential fetching

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)