Summary
This pre-RFC proposes a phased update of NixOS’s x86_64 baseline architecture, transitioning to x86-64-v2 in 2024 and subsequently to x86-64-v3 in 2027. This strategy is designed to gradually optimize NixOS for modern CPU architectures, balancing performance improvements with compatibility and transition challenges.
Background
NixOS currently supports a broad range of x86_64 processors. However, this extensive compatibility limits the utilization of advancements in newer CPU architectures. A gradual transition would allow NixOS to progressively adopt modern CPU features while maintaining broader hardware support.
Phase 1: Transition to x86-64-v2 (2024)
Implementation
-
Compiler Updates: Shift compiler flags to
-march=x86-64-v2
, targeting CPUs supporting up to SSE4.2 and SSSE3. - Evaluation: Assess compatibility and performance impacts on the existing package ecosystem.
Rationale
- Intermediate Compatibility: x86-64-v2 offers slight improved performance over the current baseline while maintaining broader compatibility, including with some older CPUs.
- Building Foundations for Phase 3: This phase sets the stage for the subsequent transition to x86-64-v3, allowing time for testing and community adaptation.
Phase 2: Transition to x86-64-v3 (2027)
Implementation
-
Compiler Adjustments: Update to
-march=x86-64-v3
, optimizing for CPUs with support for AVX2 and additional bit-manipulation instructions. - Legacy Support Strategy: Develop and maintain strategies for supporting systems incompatible with x86-64-v3.
Rationale
- Maximizing Performance: The shift to x86-64-v3 aims to fully leverage modern CPU capabilities, significantly boosting performance for various applications.
- Alignment with Industry Trends: The transition aligns NixOS with industry trends in the Linux space towards utilizing more advanced CPU features. This includes distributions like Arch Linux, CentOS, Red Hat, and openSUSE Linux distributions.
Drawbacks and Challenges
Compatibility
- Reduced Compatibility: Each phase might render NixOS incompatible with some older systems, potentially impacting a subset of the user base.
- System Types vs. Features: There’s an ongoing discussion about whether these architectural levels should be system types or features within NixOS, with implications for package compatibility and system configuration.
Migration Complexity
- Implementation Challenges: The phased approach requires meticulous planning, testing, and execution.
- Toolchain and Build System Adjustments: Accommodating new compiler flags and architecture levels in the NixOS toolchain and build systems.
Maintenance Workload
- Increased Burden: Switching architectures adds to the maintenance workload.
- Ofborg Support: Making Ofborg work nicely with the different microarchitecture levels and making sure all the tests run smoothly as well.
Contingency Plan
- Staged Rollouts with Community Feedback: Implement changes in stages, with active monitoring and adjustments based on feedback.
- Enhanced Testing and Validation: Prioritize extensive testing and validation before each phase.
- Community-Led Support for Legacy Systems: Develop initiatives for supporting users with older, incompatible hardware.
- Transparent Communication: Continuous communication with the community on transition status and issues.
- Adaptation Rather Than Reversion: Focus on adapting the approach based on encountered issues.
Alternatives
- Single-Step Transition to x86-64-v3: Potential for greater compatibility issues.
- Extended Support Periods: Prolonging support for each architecture level for smoother community adaptation.
Benchmarking
NixOS Benchmarks
-
Existing Data: Limited benchmarks are available specifically for NixOS regarding x86_64 microarchitecture levels. This scarcity underlines the need for NixOS-specific benchmarking initiatives.
PedroHLC
SuperSandro2000 PR -
Proposed Actions: Conduct a series of comprehensive benchmarks, focusing on key performance metrics across various workloads and comparing x86-64-v1, v2, and v3.
CachyOS Benchmarks
- Overview: CachyOS, an Arch Linux-based distribution, provides valuable insights with its v3 packages & kernels.
- Reference Use: Analyze CachyOS benchmark data to infer potential performance improvements in NixOS under similar conditions.
Arch Linux Benchmarks
- Findings: Arch Linux’s benchmarks provided from a maintainer in a mail list have shown a 10–20% improvement when transitioning from v1 to v3.
- Implications for NixOS: These results suggest possible performance gains for NixOS, emphasizing the need for a detailed comparison under NixOS’s unique environment.
Additional Sources
- Community Contributions: Encourage NixOS community members to share their benchmarking results.
- External Comparisons: Look at benchmarks conducted by other Linux distributions or independent reviewers to gain a broader understanding of the performance impacts.
Unresolved Questions
- Community Engagement: How to effectively communicate and implement the transition plan within the NixOS community?
- Hardware Compatibility Checks: Mechanisms for users to easily determine the compatibility of their hardware with each new baseline.
- Support Mechanisms: Strategies to support users and maintainers during each transition phase, especially those with older hardware.