Skip to content

Commit 0ddc4e0

Browse files
Limit parallel processes to CPU count (#76)
1 parent c765887 commit 0ddc4e0

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

tokenomics_decentralization/helper.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,8 @@ def get_concurrency_per_ledger():
633633
# and run in parallel without exhausting the system's memory.
634634
if max_file_size > 0:
635635
# When loaded in (a dict in) memory, each file consumes approx. 2.5x space compared to storage.
636-
concurrency[ledger] = int(system_memory_total / (2.5 * max_file_size))
636+
# Limit processes to CPU count to avoid OS process management overhead.
637+
concurrency[ledger] = min(os.cpu_count(), int(system_memory_total / (2.5 * max_file_size)))
637638
# Find if some ledger files are too large to fit in the system's available memory.
638639
if concurrency[ledger] == 0:
639640
too_large_ledgers.add(ledger)

0 commit comments

Comments
 (0)