占星学CPU调度器
Astrological CPU Scheduler

原始链接: https://github.com/zampierilucas/scx_horoscope

## scx_horoscope:基于星象的CPU调度 scx_horoscope是一个完全可用的Linux内核调度器,它使用`sched_ext`框架,并基于占星学原理做出CPU调度决策。它计算实时行星位置,根据星座亲和力对任务进行分类,并相应地动态调整CPU时间片。 该调度器基于行星统治力分配优先级——太阳用于关键进程,月亮用于交互式任务,水星用于网络活动,以此类推——并为兼容的元素星座(火星提升CPU任务,水星降低)提供加成,以及在行星逆行期间施加惩罚。月相也会影响调度,在满月期间提升交互式任务。 尽管科学上站不住脚,但该项目是一个完全可行的概念验证,可以加载到内核中,并可证明地影响任务调度。它旨在用于教育和娱乐目的,提供诸如“宇宙天气报告”和调试输出等功能,以观察占星学对系统进程的影响。它需要一个较新的内核(6.12+),并以GPL-2.0许可协议提供。

一个在Hacker News分享的项目,戏谑地实现了一个“占星CPU调度器”(github.com/zampierilucas)。该调度器根据占星相位引入性能波动——本质上,当行星处于某些星座时,它会故意降低系统速度。 这个帖子引发了有趣的反应,评论者指出可以将性能问题归咎于水星逆行或冥王星的移动。一位评论员将其比作一个“混沌猴子”,故意引入故障以测试系统弹性。 虽然显然是一个新奇项目,但讨论凸显了对系统管理复杂性的幽默看法,以及寻求解释(甚至是幽默的解释)不可预测行为的倾向。这个项目是“因为我们能做到”工程的一个轻松示例。
相关文章

原文

"Why let mere mortals decide CPU priorities when the cosmos can guide us?"

A fully functional sched_ext scheduler that makes real CPU scheduling decisions based on real-time planetary positions, zodiac signs, and astrological principles. This actually loads into the Linux kernel and schedules your system tasks. Because if the universe can influence our lives, why not our CPU scheduling too?

Demo

  • Real Planetary Calculations: Uses the astro crate for accurate geocentric planetary positions
  • Zodiac-Based Task Classification: Tasks are classified by their astrological affinities
  • Retrograde Detection: Real retrograde motion detection by comparing day-to-day positions - negative influences trigger 50% time slice penalties
  • Lunar Phase Scheduling: Moon phases affect Interactive tasks (shells, editors) with Full Moon giving 1.4x boost
  • Element Boosts & Debuffs: Fire signs boost CPU tasks (1.5x), Water signs debuff them (0.6x) - elemental oppositions create cosmic chaos
  • Cosmic Weather Reports: Get real-time astrological guidance for your system with moon phase tracking
  • Actually Works: Loads into the Linux kernel via sched_ext and schedules real system processes
  • Real BPF Integration: Uses scx_rustland_core framework for kernel-userspace communication
  • Dynamic Time Slicing: Adjusts CPU time based on astrological priority (100-1000)

Astrological Scheduling Rules

Each planet rules specific types of system tasks:

  • ☀️ Sun (Life Force): Critical system processes (PID 1, init)
  • 🌙 Moon (Emotions): Interactive tasks (shells, editors, terminals)
  • 💬 Mercury (Communication): Network and I/O tasks
  • 💖 Venus (Harmony): Desktop and UI processes
  • ⚔️ Mars (Energy): CPU-intensive tasks (compilers, video encoding)
  • 🎯 Jupiter (Expansion): Memory-heavy applications (databases, browsers)
  • ⚙️ Saturn (Structure): System daemons and kernel threads

Zodiac sign elements create elemental affinities and oppositions:

Boosted Combinations (tasks thrive under compatible elements):

  • 🔥 Fire (Aries, Leo, Sagittarius, Ophiuchus*) × CPU tasks: 1.5x boost
  • 🌬️ Air (Gemini, Libra, Aquarius) × Network tasks: 1.5x boost
  • 🌍 Earth (Taurus, Virgo, Capricorn) × System tasks: 1.4x boost
  • 💧 Water (Cancer, Scorpio, Pisces) × Memory tasks: 1.3x boost

Debuffed Combinations (elemental oppositions):

  • 💧 Water × CPU tasks: 0.6x (water dampens fire)
  • 🌍 Earth × Network tasks: 0.6x (earth blocks air)
  • 🌬️ Air × System tasks: 0.7x (air disrupts earth's structure)
  • 🔥 Fire × Memory tasks: 0.7x (fire evaporates water)

All other combinations are neutral (1.0x).

*Ophiuchus (the 13th sign) is available with --ophiuchus flag, using IAU constellation boundaries.

When a planet is in retrograde motion, tasks under its domain suffer a 50% time slice penalty. Retrograde is detected by comparing daily planetary positions - when a planet moves backward through the zodiac (negative delta in ecliptic longitude), it's retrograde.

Key retrograde effects:

  • Mercury Retrograde: Network and interactive tasks suffer
  • Mars Retrograde: CPU tasks crawl like molasses
  • Venus Retrograde: UI becomes disharmonious
  • Note: Sun and Moon never go retrograde
final_priority = base_priority × planetary_influence × element_boost
time_slice = min_slice + (base_slice - min_slice) × (priority / 1000)
if retrograde: time_slice × 0.5

Base Priorities:

  • Critical (PID 1): 1000
  • System tasks: 200
  • Interactive tasks: 150
  • Desktop/UI: 120
  • CPU/Network: 100
  • Memory: 80

Planetary Influence (when planet is direct):

  • Fire signs: 1.3x
  • Air signs: 1.2x
  • Earth signs: 1.1x
  • Water signs: 1.0x
  • Retrograde: -1.0 (triggers time slice penalty)

NOTE: userspace schedulers require kernels 6.12 or later.

If you're using NixOS, you can also add provided flake like this (25.11+ required):

  # Include this flake
  inputs.scx_horoscope.url = "github:zampierilucas/scx_horoscope";

  ...

  # Include module
  outputs = { self, nixpkgs, scx_horoscope, ... }@inputs: {
    nixosConfigurations.myhost = nixpkgs.lib.nixosSystem {
      modules = [
        scx_horoscope.nixosModules.default
      ];
    };
  };

And then somewhere later in your system configuration:

  services.scx_horoscope = {
    enable = true;

    # Add options as needed
    extraArgs = [ "--cosmic-weather" ];
  };

Requires root privileges to load into the kernel as a sched_ext scheduler.

# Build
cargo build --release

# Run with cosmic weather report and verbose output
sudo target/release/scx_horoscope --cosmic-weather -v

# Run with debug decisions to see individual task scheduling
sudo target/release/scx_horoscope --debug-decisions

# Stop: Press Ctrl+C for graceful shutdown

Astrological Options:

  • -w, --cosmic-weather - Display planetary positions and astrological guidance on startup
  • -d, --debug-decisions - Watch the cosmos make scheduling decisions in real-time
  • --ophiuchus - Use 13-sign zodiac with Ophiuchus (IAU constellation boundaries)
  • --no-retrograde - Boring mode (disables retrograde chaos)
  • -u, --update-interval <SECS> - Update planetary positions every N seconds (default: 60)

Performance Tuning:

  • -s, --slice-us <MICROSECONDS> - Base time slice duration (default: 5000)
  • --slice-us-min <MICROSECONDS> - Minimum time slice (default: 500)
  • -v, --verbose - Display detailed statistics

Run --help to see all options.

This scheduler is 100% for educational and entertainment purposes. While the astronomical calculations are real and the scheduler actually works (it really does load into the kernel and schedule tasks!), using astrology to schedule CPU tasks is:

  • Scientifically dubious
  • Cosmically hilarious
  • Fully functional with real retrograde detection and lunar phase scheduling
  • Not recommended for production systems (but it boots and runs stably)
  • Perfect for conference talks, hackathons, and proving that anything is possible

GPL-2.0-only (as required by sched_ext)

Contributions welcome! The core scheduler is working, but there's always room for more cosmic chaos:

  • Add more planetary aspects (conjunctions, oppositions, trines)
  • Add birth chart generation for processes (based on creation time)
  • Horoscope predictions for task completion times
  • Per-CPU affinity based on astrological compatibility
  • Extend moon phase effects to other task types (I/O, memory operations)
  • Norm for the hilarious and brilliant idea to schedule by the stars
  • sched_ext team for the amazing BPF scheduler framework
  • The cosmos, for providing endless entertainment

"In space, no one can hear you schedule."

Comments from people:

  • "You've made it work, but at what cost!"
联系我们 contact @ memedata.com