Files
clear-linux-documentation/guides/clear/performance.html
2024-11-04 18:48:51 +00:00

368 lines
24 KiB
HTML
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html lang="en" data-content_root="../../">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Performance &#8212; Documentation for Clear Linux* project</title>
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="../../_static/bizstyle.css?v=5283bb3d" />
<link rel="stylesheet" type="text/css" href="../../_static/copybutton.css?v=76b2166b" />
<script src="../../_static/documentation_options.js?v=5929fcd5"></script>
<script src="../../_static/doctools.js?v=9bcbadda"></script>
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../../_static/clipboard.min.js?v=a7894cd8"></script>
<script src="../../_static/copybutton.js?v=a56c686a"></script>
<script src="../../_static/bizstyle.js"></script>
<link rel="canonical" href="https://clearlinux.github.io/clear-linux-documentation/guides/clear/performance.html" />
<link rel="icon" href="../../_static/favicon.ico"/>
<link rel="author" title="About these documents" href="../../about.html" />
<link rel="index" title="Index" href="../../genindex.html" />
<link rel="search" title="Search" href="../../search.html" />
<link rel="next" title="OS Security" href="security.html" />
<link rel="prev" title="mixer" href="mixer.html" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
<!--[if lt IE 9]>
<script src="_static/css3-mediaqueries.js"></script>
<![endif]-->
</head><body>
<div class="related" role="navigation" aria-label="Related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="security.html" title="OS Security"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="mixer.html" title="mixer"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="../../index.html">Documentation for Clear Linux* project</a> &#187;</li>
<li class="nav-item nav-item-1"><a href="../index.html" accesskey="U">Guides</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Performance</a></li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<section id="performance">
<span id="id1"></span><h1>Performance<a class="headerlink" href="#performance" title="Link to this heading"></a></h1>
<p>Clear Linux* OS is built with optimizations across the whole stack for improved
performance. Clear Linux OS achieves its performance through a variety of design decisions
and software building techniques.</p>
<nav class="contents local" id="contents">
<ul class="simple">
<li><p><a class="reference internal" href="#overview" id="id2">Overview</a></p></li>
<li><p><a class="reference internal" href="#software-build-toolchain" id="id3">Software build toolchain</a></p></li>
<li><p><a class="reference internal" href="#kernel" id="id4">Kernel</a></p></li>
<li><p><a class="reference internal" href="#operating-system" id="id5">Operating system</a></p></li>
<li><p><a class="reference internal" href="#related-topics" id="id6">Related topics</a></p></li>
</ul>
</nav>
<section id="overview">
<h2><a class="toc-backref" href="#id2" role="doc-backlink">Overview</a><a class="headerlink" href="#overview" title="Link to this heading"></a></h2>
<p>The Clear Linux OS philosophy is to do everything with performance in mind. The Clear Linux OS team
applies this philosophy in the projects codebase and operating culture.</p>
<p>Below are some examples of the Clear Linux OS philosophy:</p>
<dl class="simple">
<dt><strong>Consider performance holistically.</strong></dt><dd><p>Performance optimizations are considered across hardware and software. Clear Linux OS
shows the performance potential of a holistic approach on Linux, using Intel®
architecture with optimizations across the full stack.</p>
</dd>
<dt><strong>Optimize for runtime performance.</strong></dt><dd><p>In general, Clear Linux OS will trade the one-time cost of longer build time and larger
storage footprint for the repeated benefit of improved runtime performance.
Clear Linux OS users benefit from the optimized software but arent affected by the
increased build time because the Clear Linux OS team builds the software before
distributing it to Clear Linux OS clients.</p>
</dd>
<dt><strong>Optimize performance for server and cloud use cases first.</strong></dt><dd><p>Design decisions that optimize performance for server and cloud also benefit
other use cases, such as IoT devices and desktop clients.</p>
</dd>
</dl>
<p>Clear Linux OS has become well-known for the performance it can deliver.
<a class="reference external" href="https://www.phoronix.com/scan.php?page=news_topic&amp;q=Clear+Linux">Phoronix publishes
Linux performance comparisons</a>
that include Clear Linux OS.</p>
</section>
<section id="software-build-toolchain">
<h2><a class="toc-backref" href="#id3" role="doc-backlink">Software build toolchain</a><a class="headerlink" href="#software-build-toolchain" title="Link to this heading"></a></h2>
<p>Clear Linux OS uses many techniques in its software build toolchain to improve software
performance, such as aggressive compiler flags and CPU-specific optimizations.
If maintained manually, these techniques can become complex to support due to
the volume of packages and the potential for technical drift of package
performance configurations. The Clear Linux OS team built the <a class="reference internal" href="autospec.html#autospec"><span class="std std-ref">autospec</span></a> tool to
manage this complexity and to apply the techniques used in the software build
toolchain across the entire project. autospec is available as part of the OS for
developers to use when they build their own projects on Clear Linux OS.</p>
<section id="latest-versions-of-compilers-and-low-level-libraries">
<h3>Latest versions of compilers and low-level libraries<a class="headerlink" href="#latest-versions-of-compilers-and-low-level-libraries" title="Link to this heading"></a></h3>
<p>Clear Linux OS is a rolling release distribution and follows upstream software
repositories, including compilers and libraries, for updates. Clear Linux OS includes
upstream source-level optimizations as soon as theyre available.</p>
</section>
<section id="a-benchmark-approach-to-compiler-performance">
<h3>A benchmark approach to compiler performance<a class="headerlink" href="#a-benchmark-approach-to-compiler-performance" title="Link to this heading"></a></h3>
<p>Clear Linux OS chooses the compiler used to build each software package on a case-by-case
basis to maximize performance. Typically, Clear Linux OS uses the open source <a class="reference external" href="https://gcc.gnu.org/">GNU Compiler
Collection</a> (GCC) with the standard low-level
libraries <a class="reference external" href="https://www.gnu.org/software/libc/">Glibc</a> and
<a class="reference external" href="https://gcc.gnu.org/onlinedocs/libstdc++/">libstdc++</a> for C and C++
programming languages. If there is a performance advantage, Clear Linux OS will build
packages with <a class="reference external" href="https://clang.llvm.org/">Clang / LLVM</a>.</p>
<p>Clear Linux OS uses patched compilers and low-level libraries for exact control of the
software build. Patches include changes that default to more aggressive
optimizations or optimizations that havent yet been merged upstream.</p>
<p>View the full list of patches in the autospec repositories on GitHub:</p>
<ul class="simple">
<li><p><a class="reference external" href="https://github.com/clearlinux-pkgs/gcc">https://github.com/clearlinux-pkgs/gcc</a></p></li>
<li><p><a class="reference external" href="https://github.com/clearlinux-pkgs/glibc">https://github.com/clearlinux-pkgs/glibc</a></p></li>
<li><p><a class="reference external" href="https://github.com/clearlinux-pkgs/llvm">https://github.com/clearlinux-pkgs/llvm</a></p></li>
</ul>
</section>
<section id="aggressive-compiler-flags">
<h3>Aggressive compiler flags<a class="headerlink" href="#aggressive-compiler-flags" title="Link to this heading"></a></h3>
<p>Clear Linux OS uses aggressive
<a class="reference external" href="https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html">compiler flags</a> to
optimize software builds for runtime performance. Some significant flags that
Clear Linux OS often implements are:</p>
<dl>
<dt><a class="reference external" href="https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html">mtune and march</a></dt><dd><p>Options used to tune generated code with optimized instructions for specific
CPU types instead of creating generic code for maximum compatibility.</p>
<p>Clear Linux OS defines its minimum hardware requirements to be second-generation
Intel® microarchitecture code name Westmere (released in 2010) or later.
This enables compiler optimizations that are available only on newer
architectures. Whenever possible, Clear Linux OS tunes code for the Haswell generation
processors or newer.</p>
<p>Clear Linux OS sets <strong class="command">march=westmere</strong> and <strong class="command">mtune=haswell</strong>.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Clear Linux OS doesnt require Advanced Encryption Standard (AES), so it should
run on some Intel CPUs from the first generation of Intel® microarchitecture code name Nehalem (released in 2008). Refer to the
<a class="reference external" href="https://docs.01.org/clearlinux/latest/reference/system-requirements.html">recommended minimum system requirements</a> for specific requirements.</p>
</div>
</dd>
<dt><a class="reference external" href="https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html">O3</a></dt><dd><p>The largest preset of compiler options optimizations for performance. O3
favors runtime performance.</p>
<p>View the “Optimize Options” section of the GCC man page for additional
information: <strong class="command">man gcc</strong></p>
</dd>
<dt><a class="reference external" href="https://gcc.gnu.org/onlinedocs/gccint/LTO.html">LTO</a></dt><dd><p>Link-time optimization that performs an optimization between compiled object
files and creation of executable binaries by adding extra information to the
compiled object to help the linker.</p>
</dd>
<dt><a class="reference external" href="https://en.wikipedia.org/wiki/Profile-guided_optimization">PGO</a></dt><dd><p>Profile guided optimization or field guided optimization performs
optimization based on information sampled during the execution of the program.</p>
</dd>
</dl>
<p>Compiler flags are set at different levels in the Clear Linux OS build environment:</p>
<dl>
<dt>User flags</dt><dd><p>The set of default flags used by Clear Linux OS when a user compiles software
from source. The flags are exported as system-wide environment variables from
the
<a class="reference external" href="https://github.com/clearlinux-pkgs/filesystem/blob/master/profile.x86_64">/usr/share/defaults/etc/profile</a> file to the users shell by default. These are the
standard variables read by the compiler, named <strong class="command">*FLAGS</strong>, depending
on the compiler.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Source code may come with software build systems that
override these values. This will cause a difference in expected flags.
The Clear Linux OS autospec tooling will attempt to ignore these overrides, but
the build system may still need patching. A manual build will not ignore
the build system override values if they exist.</p>
</div>
</dd>
<dt>Global flags</dt><dd><p>Compiler flags applied at a global level for all packages. The Clear Linux OS RPM
configuration (<a class="reference external" href="https://github.com/clearlinux/clr-rpm-config">clr-rpm-config</a>)
contains global compiler flags. Search the <code class="file docutils literal notranslate"><span class="pre">macros</span></code> file for
<strong class="command">global_cflags</strong> and search the <code class="file docutils literal notranslate"><span class="pre">rpmrc</span></code> file for
<strong class="command">optflags</strong>. Global compiler flags may be overridden.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Clear Linux OS doesnt use RPMs to install software. Clear Linux OS
distributes software in the form of <a class="reference internal" href="bundles.html#bundles-guide"><span class="std std-ref">Bundles</span></a>. The RPM format
is only used during the Clear Linux OS build process as a way to resolve
dependencies.</p>
</div>
</dd>
<dt>Per-package flags</dt><dd><p>Compiler flags applied at a per-package level. The packages autospec
repository contains the package-specific compiler flags. Search the
<code class="file docutils literal notranslate"><span class="pre">.spec</span></code> file for the
section starting with <strong class="command">export CFLAGS</strong>.</p>
</dd>
</dl>
</section>
<section id="multiple-builds-of-libraries-with-cpu-specific-optimizations">
<h3>Multiple builds of libraries with CPU-specific optimizations<a class="headerlink" href="#multiple-builds-of-libraries-with-cpu-specific-optimizations" title="Link to this heading"></a></h3>
<p>To fully use the capabilities in different generations of CPU hardware, Clear Linux OS
will perform multiple builds of libraries with CPU-specific optimizations. For
example, Clear Linux OS builds libraries with Intel® Advanced Vector Extensions 2 (Intel®
AVX2) and Intel® Advanced Vector Extensions 512 (Intel® AVX-512). Clear Linux OS can then
dynamically link to the library with the newest optimization based on the
processor in the running system. Runtime libraries used by ordinary applications
benefit from these CPU specific optimizations.</p>
<p>The autospec repository for Python* shows an example of this optimization:
<a class="reference external" href="https://github.com/clearlinux-pkgs/python3">https://github.com/clearlinux-pkgs/python3</a></p>
</section>
</section>
<section id="kernel">
<h2><a class="toc-backref" href="#id4" role="doc-backlink">Kernel</a><a class="headerlink" href="#kernel" title="Link to this heading"></a></h2>
<section id="a-modern-kernel-with-variants-optimized-for-different-platforms">
<h3>A modern kernel with variants optimized for different platforms<a class="headerlink" href="#a-modern-kernel-with-variants-optimized-for-different-platforms" title="Link to this heading"></a></h3>
<p>Clear Linux OS is a rolling release distribution that uses the newest upstream Linux
kernel. The Linux kernel has frequent updates which can include performance
enhancements. Its a policy of the Clear Linux OS team to try to upstream any performance
enhancements in the Linux kernel for all to use.</p>
<p>Clear Linux OS <a class="reference external" href="https://docs.01.org/clearlinux/latest/guides/clear/compatible-kernels.html">builds different kernel variants</a> for compatibility with specific platforms.
For example, kernels meant to run on virtual machines skip support for much of
the physical hardware that doesnt show up in VM environments and will slow down
boot.</p>
<p>View the kernel configuration and patches to the default native kernel in the
autospec repository: <a class="reference external" href="https://github.com/clearlinux-pkgs/linux/">https://github.com/clearlinux-pkgs/linux/</a></p>
</section>
<section id="utility-to-enforce-kernel-runtime-parameters">
<h3>Utility to enforce kernel runtime parameters<a class="headerlink" href="#utility-to-enforce-kernel-runtime-parameters" title="Link to this heading"></a></h3>
<p>The Linux kernel exposes parameters for tuning the behavior of drivers and
devices such as certain buffers and resource management strategies. Clear Linux OS uses a
small utility, <a class="reference external" href="https://github.com/clearlinux-pkgs/clr-power-tweaks">clr-power-tweaks</a>,
to set and enforce kernel parameter values weighted towards performance upon
boot. View the set performance values by running <strong class="command">sudo clr_power --debug</strong>.</p>
</section>
</section>
<section id="operating-system">
<h2><a class="toc-backref" href="#id5" role="doc-backlink">Operating system</a><a class="headerlink" href="#operating-system" title="Link to this heading"></a></h2>
<p>Operating system and software build-time optimizations set the stage for high
performance. Decisions made after the installation of Clear Linux OS are equally as
important.</p>
<section id="cpu-performance-governor">
<h3>CPU performance governor<a class="headerlink" href="#cpu-performance-governor" title="Link to this heading"></a></h3>
<p>Clear Linux OS uses the performance CPU governor which calls for the CPU to operate at
maximum clock frequency. In other words, P-state P0. The idea behind prioritizing
maximum CPU performance is that the faster a program finishes execution, the
faster the CPU can return to a low energy idle state. See the <a class="reference external" href="https://docs.01.org/clearlinux/latest/guides/maintenance/cpu-performance.html">CPU Power and
Performance documentation</a>
for further details.</p>
</section>
<section id="restructured-boot-sequence">
<h3>Restructured boot sequence<a class="headerlink" href="#restructured-boot-sequence" title="Link to this heading"></a></h3>
<p>To optimize boot speed, Clear Linux OS uses a restructured order for boot processes that
minimizes the time services wait on slow operations and the time boot processes
wait on each other.</p>
<p>Systemd-bootchart is a tool for graphing the boot sequence and writes logs to a
file under <code class="file docutils literal notranslate"><span class="pre">/run/log</span></code>. The tool and corresponding log file make diagnosing slow
boot problems easier. All Clear Linux OS systems have <a class="reference external" href="https://github.com/systemd/systemd-bootchart">systemd-bootchart</a> enabled by default for every boot. systemd-bootchart configuration is
non-blocking to not materially slow down boot performance.</p>
</section>
</section>
<section id="related-topics">
<h2><a class="toc-backref" href="#id6" role="doc-backlink">Related topics</a><a class="headerlink" href="#related-topics" title="Link to this heading"></a></h2>
<ul class="simple">
<li><p><a class="reference internal" href="../maintenance/cpu-performance.html#cpu-performance"><span class="std std-ref">CPU Power and Performance</span></a></p></li>
<li><p><a class="reference external" href="https://clearlinux.org/blogs-news/linux-os-linux-developers">A Linux* OS for Linux Developers</a></p></li>
<li><p><a class="reference external" href="https://clearlinux.org/news-blogs/performance-race">The Performance Race</a></p></li>
<li><p><a class="reference external" href="https://clearlinux.org/news-blogs/boosting-python-profile-guided-platform-specific-optimizations">Boosting Python* from profile-guided to platform-specific optimizations</a></p></li>
<li><p><a class="reference external" href="https://clearlinux.org/news-blogs/transparent-use-library-packages-optimized-intel-architecture">Transparent use of library packages optimized for Intel® architecture</a></p></li>
</ul>
<p><em>Intel and the Intel logo are trademarks of Intel Corporation or its subsidiaries.</em></p>
</section>
</section>
<div class="clearer"></div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="Main">
<div class="sphinxsidebarwrapper">
<p class="logo"><a href="../../index.html">
<img class="logo" src="../../_static/clearlinux.png" alt="Logo of Clear Linux* Project Docs"/>
</a></p>
<div>
<h3><a href="../../index.html">Table of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Performance</a><ul>
<li><a class="reference internal" href="#overview">Overview</a></li>
<li><a class="reference internal" href="#software-build-toolchain">Software build toolchain</a><ul>
<li><a class="reference internal" href="#latest-versions-of-compilers-and-low-level-libraries">Latest versions of compilers and low-level libraries</a></li>
<li><a class="reference internal" href="#a-benchmark-approach-to-compiler-performance">A benchmark approach to compiler performance</a></li>
<li><a class="reference internal" href="#aggressive-compiler-flags">Aggressive compiler flags</a></li>
<li><a class="reference internal" href="#multiple-builds-of-libraries-with-cpu-specific-optimizations">Multiple builds of libraries with CPU-specific optimizations</a></li>
</ul>
</li>
<li><a class="reference internal" href="#kernel">Kernel</a><ul>
<li><a class="reference internal" href="#a-modern-kernel-with-variants-optimized-for-different-platforms">A modern kernel with variants optimized for different platforms</a></li>
<li><a class="reference internal" href="#utility-to-enforce-kernel-runtime-parameters">Utility to enforce kernel runtime parameters</a></li>
</ul>
</li>
<li><a class="reference internal" href="#operating-system">Operating system</a><ul>
<li><a class="reference internal" href="#cpu-performance-governor">CPU performance governor</a></li>
<li><a class="reference internal" href="#restructured-boot-sequence">Restructured boot sequence</a></li>
</ul>
</li>
<li><a class="reference internal" href="#related-topics">Related topics</a></li>
</ul>
</li>
</ul>
</div>
<div>
<h4>Previous topic</h4>
<p class="topless"><a href="mixer.html"
title="previous chapter">mixer</a></p>
</div>
<div>
<h4>Next topic</h4>
<p class="topless"><a href="security.html"
title="next chapter">OS Security</a></p>
</div>
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="../../_sources/guides/clear/performance.rst.txt"
rel="nofollow">Show Source</a></li>
</ul>
</div>
<search id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="../../search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
<input type="submit" value="Go" />
</form>
</div>
</search>
<script>document.getElementById('searchbox').style.display = "block"</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="Related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../../genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="security.html" title="OS Security"
>next</a> |</li>
<li class="right" >
<a href="mixer.html" title="mixer"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="../../index.html">Documentation for Clear Linux* project</a> &#187;</li>
<li class="nav-item nav-item-1"><a href="../index.html" >Guides</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Performance</a></li>
</ul>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2022 Intel Corporation. All Rights Reserved..
Last updated on Nov 04, 2024.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 8.1.3.
</div>
</body>
</html>