显示HN:用LLM替换我的操作系统进程调度器
Show HN: Replacing my OS process scheduler with an LLM

原始链接: https://github.com/mprajyothreddy/brainkernel

## BrainKernel:傲娇的进程管理器 BrainKernel 是一款新的、感知上下文的基于终端的 Linux 进程管理器,超越了简单的 CPU 使用率监控。它利用 LLM(由 Llama 3 提供支持)*评估* 正在运行的进程——识别“关键系统更新”与“厂商臃肿软件”——并允许用户智能地管理它们。 主要功能包括“外交豁免权”保护浏览器等基本应用程序,“嘲讽模式”在终止进程前对其进行嘲讽,以及“耻辱榜”记录最佳终止事件。它提供“专注模式”以暂停分散注意力的后台应用程序,并通过 Delta 缓存以低于 1% 的 CPU 使用率高效运行。 BrainKernel 支持云端(Groq API)和本地(Ollama)LLM 部署。它通过 PID 回收检查和去抖动来优先考虑安全性,以防止意外终止,同时也允许社区贡献其臃肿软件列表。本质上,BrainKernel 旨在成为一种更智能、更有趣的系统进程管理方式。

一位开发者在Hacker News分享了一个项目,用大型语言模型(LLM)取代了操作系统的进程调度器,名为“BrainKernel”。该系统利用快速LLM(Llama 3 @ 800t/s 通过Groq)和定制的TUI,分析进程——考虑父进程和磁盘I/O等上下文——然后根据进程是否被认为有用或“臃肿软件”来“降级、限制或杀死”它们。 开发者承认该项目效率低下,可能消耗大量电力,但认为节省的时间可以证明其价值。它并非*真正*的调度器替代品,因为它在用户空间运行,并通过暂停进程来有效地否决操作系统调度器(NTOS)。 该项目被定位为自动化手动管理进程的用户的行为,更像是一个“调度器管理器”而不是完全替代。它旨在解决开发者自己对资源使用的焦虑,特别是像Dropbox通过Chromium利用过多资源的情况。
相关文章

原文
┏┓ ┏━┓┏━┓╻┏┓╻╻┏ ┏━╸┏━┓┏┓╻┏━╸╻  
┣┻┓┣┳┛┣━┫┃┃┗┫┣┻┓┣╸ ┣┳┛┃┗┫┣╸ ┃  
┗━┛╹┗╸╹ ╹╹╹ ╹╹ ╹┗━╸╹┗╸╹ ╹┗━╸┗━╸                                                                                                             

"What if the Linux Kernel had a prefrontal cortex?"

The Sassy, Context-Aware Process Manager

"Task Manager is boring. BrainKernel is judgmental."

Demo

BrainKernel is a TUI (Terminal User Interface) process manager that uses an LLM to analyze why a process is running. It doesn't just show CPU usage; it looks at parentage, disk I/O, and behavior history to distinguish between "Critical System Update" (Safe) and "Vendor Bloatware" (Kill).

v3.4.0 "The Silent Guardian" Update:

  • Diplomatic Immunity: Automatically detects and protects browsers, chat apps, and IDEs. It will roast them for high CPU usage, but it will never kill them.
  • Stealth Mode: Disguises API traffic to work seamlessly with cloud providers (Groq).
  • <1% CPU: Uses Delta Caching to monitor 300+ processes without lagging your machine.
  • Cloud & Local: Built for Groq (Cloud) or Ollama (Local). Perfect for laptops that can't run local models.
  • Context Aware: It knows that chrome.exe using 40% CPU is probably a video call (Ignore), but McAfee.exe using 40% CPU is a crime (Kill).
  • Roast Mode: It doesn't just kill processes; it insults them first.
  • Hall of Shame: Keeps a permanent record of the worst offenders and the roasts they received.
  • Focus Mode: Define a "Focus App" (e.g., VS Code), and it will aggressively suspend background distractions.

Quick Start (Cloud / Groq)

Since you aren't running a local LLM, you will use the Groq API (It's free and extremely fast).

pip install psutil textual

3. Add Your Brain (API Key)

  1. Get a free API Key from console.groq.com.
  2. Launch BrainKernel.
  3. Press k to open the Key Manager.
  4. Paste your key (starts with gsk_...) and hit Enter.
    • Your key is saved locally in ~/.brainkernel.json.
Key Action Description
k Key Config Enter your Groq API key.
n Roast Now Force the AI to analyze and roast the top CPU hog immediately.
p Protect Toggle protection for the selected PID (Green status).
x Begone! Ban a process name. Future instances will be auto-killed on sight.
s Shame View the "Hall of Shame" (best roasts log).
f Focus Set a "Focus App". Distractions using >5% CPU will be suspended.
r Resume Resume all suspended processes.
q Quit Exit BrainKernel.

BrainKernel is designed to be safe, even when the AI is sassy.

  1. Diplomatic Immunity: Hardcoded protection for browser, social, gaming, and dev_tool categories.
  2. PID Safety Lock: Before killing anything, it verifies the target's create_time. If a PID was recycled by the OS in the last 100ms, the kill is aborted.
  3. Debouncing: It remembers decisions for 5 minutes. It won't spam you about the same process twice.

Found a new vendor bloatware process? PRs welcome to the BLOATWARE list in main.py.


Built with Python & Textual. Powered by Llama 3.

联系我们 contact @ memedata.com