codegen-units and link-time optimization (LTO) affect different parts of a Rust build, so neither is a universal substitute for the other. More codegen units can improve compilation parallelism; LTO can give the optimizer a wider view of the program, often at the cost of link time. For release builds, compare the combinations that match your goals—build time, runtime performance, or binary size—on your actual project and deployment target.
What each setting controls
Codegen units control parallel code generation
The rustc -C codegen-units option, exposed in Cargo profiles as codegen-units, sets the maximum number of code-generation units into which a crate is split. LLVM can process multiple units in parallel. That can shorten compilation, but may reduce optimization opportunities and produce slower code. As the Rust Project puts it in its Codegen Options documentation, “Increasing parallelism may speed up compile times, but may also produce slower code.” Neither effect is guaranteed for every project or machine.
Setting the value to 1 removes that code-generation parallelism and may improve generated-code performance, while potentially slowing compilation. It does not mean “turn LTO on”; it is a separate control.
LTO broadens optimization at link time
LTO lets LLVM optimize with information available at link time. Fat LTO attempts optimization across crates in the dependency graph and can make linking take longer. Thin LTO is designed to take substantially less time than fat LTO while achieving similar performance gains, according to the Rust Project’s Codegen Options documentation. The same documentation notes that for larger projects such as the Rust compiler, ThinLTO can even produce better performance than fat LTO. These are general documentation observations, not a guarantee for your application.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Scan for outdated or missing drivers - takes under a minute3Clear out junk files and repair common Windows errors#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
Understand what “LTO off” means in Cargo
Rust has an important distinction between cross-crate LTO and thin local LTO. If rustc’s -C lto is not specified, it attempts thin local LTO across codegen units within the local crate; this is not cross-crate LTO. That behavior is disabled when codegen-units = 1 or opt-level = 0.
In Cargo, lto = false means thin local LTO, while lto = "off" disables LTO. The default development profile uses lto = false. So a build described casually as “LTO off” may still use thin local LTO. Check the effective profile and spell out the setting you intend. See the Cargo Profiles reference and the rustc Codegen Options documentation.
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
Defaults and profile differences matter
Cargo documents codegen-units = 16 as the default for non-incremental builds and codegen-units = 256 for incremental builds. Its development profile enables incremental compilation by default and uses 256 codegen units. These profile differences can change both compilation behavior and what a benchmark is actually comparing.
Before drawing conclusions from a flag change, inspect and record the profile settings for at least opt-level, incremental, codegen-units, and lto. Cargo’s Profiles reference documents the profile keys and defaults.
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
Which setting should you try?
| Your priority | A sensible starting point | What to evaluate |
|---|---|---|
| Fast edit/build iteration | Keep the normal development profile and its parallel code generation unless measurement identifies a different bottleneck. | Incremental rebuild time and the actual stage that limits your workflow. |
| Release runtime performance | Benchmark ThinLTO against your current release baseline. | Runtime on the target workload, plus clean build and link time. |
| Considering fat LTO | Try it only after establishing a baseline, and retain it only if its result justifies the extra link cost. | Whether the measured runtime or size gain matters enough to offset linking time. |
| Considering one codegen unit | Test codegen-units = 1 separately and in combination with LTO. |
Compilation and link time as well as generated-program behavior; this setting also changes whether implicit thin local LTO applies. |
| Rust linked with C or C++ | Check linker-plugin LTO requirements for all participating toolchains and the linker. | LLVM toolchain compatibility, matching thin or fat mode, and linker plugin support. |
This is a benchmark plan, not a promise that any option will win. The official documentation does not establish a universal best setting for ordinary Rust applications.
How to make a useful comparison
- Use the release profile that you deploy. Do not compare a development build with a release build or rely on an assumed default. Record the effective profile values, especially optimization level, incremental compilation, codegen units, and LTO.
- Change one meaningful variable at a time. Compare your baseline with a ThinLTO build; evaluate fat LTO or one codegen unit as distinct follow-up variants. If you test combinations, record each combination rather than attributing the result to one flag.
- Keep the environment stable. Use the same Rust toolchain, target, dependencies, hardware, and workload for each run.
- Record build stages separately. Measure clean compilation and linking separately, and measure incremental rebuild time if that matters to your workflow.
- Measure the outcome you actually need. Run the representative target workload for runtime performance, or compare binary size if that is a project requirement. Do not treat a faster build as proof of a faster program.
Compatibility notes for LTO
Embedded LLVM bitcode
Rust requires LLVM bitcode for LTO. Combining -C embed-bitcode=no with -C lto is invalid and causes rustc to abort. Cargo manages the related rustc options through the profile’s lto setting. See the Rust Project’s Codegen Options documentation.
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
Rust and C/C++ in one linked program
Cross-language optimization uses linker-plugin LTO, which defers optimization to the linker. Documented cases include Rust static libraries used from C or C++, and C or C++ dependencies linked into Rust. Participating objects need LLVM-based toolchains using the same LTO mode—thin or fat—and the linker must support the LLVM plugin. Those requirements are additional to choosing a Cargo profile value. The details are in the rustc Linker-plugin-based LTO documentation.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Keep rustc-specific performance claims in scope
The Rust Compiler Development Guide says that enabling LTO for rustc on Linux has produced speed-ups of up to 10%. That figure concerns building rustc, not an expected gain for an arbitrary Rust application. The guide says this configuration is currently supported and tested only on x86_64-unknown-linux-gnu, offers no guarantees for other targets, and warns that LTO-optimized rustc produces miscompilations on Windows. Read the optimized-build guidance before applying that rustc-specific setup to compiler development.
Quick Recap
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

