Files
2026-05-25 05:08:11 +00:00

27 lines
865 B
Python

import ctypes
import os
from .ksm_node import EnableProcessKSMNode
# 1. Automatically apply KSM system-wide to the process on boot
PR_SET_MEMORY_MERGE = 67
try:
libc = ctypes.CDLL(None)
res = libc.prctl(PR_SET_MEMORY_MERGE, 1, 0, 0, 0)
if res == 0:
print(f"\n[KSM AUTOMATION] Successfully enabled KSM on startup for ComfyUI PID: {os.getpid()}\n")
else:
print(f"\n[KSM AUTOMATION] Failed to enable KSM on startup. Code: {res}\n")
except Exception as e:
print(f"\n[KSM AUTOMATION] Error enabling KSM: {e}\n")
# 2. Keep the node registration intact so you can still use it as a diagnostic tool
NODE_CLASS_MAPPINGS = {
"EnableProcessKSMNode": EnableProcessKSMNode
}
NODE_DISPLAY_NAME_MAPPINGS = {
"EnableProcessKSMNode": "Enable Process KSM (Linux Only)"
}
__all__ = ['NODE_CLASS_MAPPINGS', 'NODE_DISPLAY_NAME_MAPPINGS']