fix(phase2): 并行编译 worker 数按可用内存动态限制,修复内存不足 OOM
系统可用内存低(Trae CN/Java 占用后仅剩 ~1GB)时,ProcessPoolExecutor 按 cpu_count 开满 worker,多进程编译内存叠加在 StructGen.finalize 拼接 module IR 时 MemoryError(编译 StubMergerTopo.vp 报错即此)。新增 _PickWorkerCount:GlobalMemoryStatusEx 读 ullAvailPhys,按 per_worker_mb 估算 worker 上限(翻译 700MB / llc 400MB),内存不足自动降为单 worker 串行,内存充足回落 cpu_count。StructGen.finalize 拼接改中间变量拆分, 降低单 worker 峰值副本。
This commit is contained in:
1 parent
e37cdf2eb0
commit
12207e91d8
2 files changed
+44
-5
No files matched your search
@@ -201,7 +201,9 @@ class StructGenMixin:
|
||||
if insert_pos == -1:
|
||||
insert_pos = header_end
|
||||
struct_block: str = '\n'.join(struct_defs) + '\n'
|
||||
ir_text = ir_text[:insert_pos + 1] + struct_block + ir_text[insert_pos + 1:]
|
||||
_ir_head = ir_text[:insert_pos + 1]
|
||||
_ir_tail = ir_text[insert_pos + 1:]
|
||||
ir_text = _ir_head + struct_block + _ir_tail
|
||||
# 仅含特殊字符(数字开头或含点)的 struct 名需要加引号:
|
||||
# 合并为单个正则一次扫描全文本,替代逐 name 各自 re.sub(每个 name
|
||||
# 一次 O(text) 扫描)。lookahead 边界排除保证各备选互斥,语义等价。
|
||||
|
||||
Reference in new issue
Block a user