Memory Tuning - Wyatt's Notes
DDR Memory Generations
Section titled “DDR Memory Generations”DDR4 vs DDR5
Section titled “DDR4 vs DDR5”DDR5 represents a fundamental shift in memory architecture. The comparison is not merely about speed — the power delivery model, signal integrity, and error correction mechanisms are all different.
| Parameter | DDR4 | DDR5 |
|---|---|---|
| Voltage | 1.2 V (standard) | 1.1 V (standard) |
| Bank Groups | 4 (16 banks) | 8 (32 banks) |
| Burst Length | 8 (BL8) | 16 (BL16) |
| Prefetch | 8n | 16n |
| VDDQ (I/O Voltage) | 1.2 V (same as VDD) | 1.1 V (separate from VDD) |
| PMIC | On motherboard | On DIMM (on-die) |
| ECC (base) | Optional | Optional (via ECC bits) |
| Pin Count (desktop) | 288 | 288 (notch position different) |
| Max Standard Speed | 3200 MT/s | 4800 MT/s (JEDEC) |
| Typical Enthusiast Speed | 3600–4266 MT/s | 6000–8400 MT/s |
Key Architectural Differences
Section titled “Key Architectural Differences”DDR5 moves the power management IC (PMIC) from the motherboard onto the DIMM itself. This means each DIMM manages its own power regulation, reducing the burden on the motherboard VRM. It also means you Cannot adjust VDDQ/VPP independently per DIMM from the motherboard — the DIMM”s PMIC handles this Internally.
DDR5 doubles the bank group count (from 4 to 8) and doubles the burst length (from BL8 to BL16). This means each activation can transfer 64 bytes per bank group instead of 32 bytes, improving Efficiency for sequential access patterns. However, the double burst length means DDR5 has higher CAS latency in absolute nanoseconds at equivalent CAS latencies in clock cycles.
Latency in Real Terms
Section titled “Latency in Real Terms”Clock cycle latency alone is misleading. What matters is actual access time in nanoseconds:
| Speed (MT/s) | CL | CAS Latency (ns) |
|---|---|---|
| DDR4-3200 | 14 | 8.75 |
| DDR4-3600 | 16 | 8.89 |
| DDR5-4800 | 40 | 16.67 |
| DDR5-5600 | 36 | 12.86 |
| DDR5-6000 | 30 | 10.00 |
| DDR5-6400 | 32 | 10.00 |
| DDR5-7200 | 34 | 9.44 |
DDR5-6000 CL30 matches DDR4-3200 CL14 in actual latency while delivering nearly double the Bandwidth. This is why DDR5-6000 is considered the sweet spot for AMD Zen 4 and Intel 13th/14th Gen.
Memory Timings
Section titled “Memory Timings”Primary Timings
Section titled “Primary Timings”The four primary timings define the basic memory access pattern:
| Timing | Full Name | Description |
|---|---|---|
| CL (tCL) | CAS Latency | Clock cycles between a READ command and data availability on the bus |
| tRCD | RAS to CAS Delay | Clock cycles between activating a row and issuing a READ/WRITE command |
| tRP | RAS Precharge | Clock cycles between precharging one row and activating another row |
| tRAS | Active to Precharge | Minimum clock cycles a row must remain active before precharging |
These four timings are commonly expressed as CL-tRCD-tRP-tRAS (e.g., 16-18-18-38).
Timing Relationships
Section titled “Timing Relationships”The primary timings are not independent. They are related by the DRAM’s electrical characteristics:
This is the minimum constraint. In practice, tRAS is set to tRCD + tRP + a small margin (2–8 Cycles). Setting tRAS too low relative to tRCD + tRP can cause data corruption because the memory Cell does not have enough time to hold a charge before precharge.
The total access latency for a random read (worst case, row miss) is:
Secondary Timings
Section titled “Secondary Timings”Secondary timings have a smaller but measurable impact on performance:
| Timing | Full Name | Description |
|---|---|---|
| tRC | Row Cycle Time | Minimum time between activating the same row again. Equal to tRAS + tRP. |
| tFAW | Four Activate Window | Minimum time between four different activate commands. Critical for 2R/4R DIMMs. |
| tRRD_S | Row to Row Delay (Same Bank Group) | Delay between activating rows in the same bank group |
| tRRD_L | Row to Row Delay (Different Bank Group) | Delay between activating rows in different bank groups |
| tCWL | CAS Write Latency | Write equivalent of CL. Equal to or CL - 1. |
| tWR | Write Recovery Time | Time after a WRITE before the row can be precharged |
Tertiary Timings
Section titled “Tertiary Timings”Tertiary timings have a small impact but can be the difference between stability and instability at Tight settings:
| Timing | Description |
|---|---|
| tRFC | Refresh Cycle Time — time to complete a full DRAM refresh. Very long on DDR5 (500+ cycles) and often the biggest bottleneck. |
| tREFI | Refresh Interval — time between refresh cycles. Higher = better performance but riskier. |
| tRDWR | Read to Write turnaround — bus turnaround time when switching from reads to writes. |
| tWRRD | Write to Read turnaround — bus turnaround time when switching from writes to reads. |
| tRTT | Read to Read turnaround (different ranks) — time between reads to different ranks on the same channel. |
Interpreting Timing Strings
Section titled “Interpreting Timing Strings”A full timing string for DDR5 might look like:
30-36-36-76-58 (CL-tRCD-tRP-tRAS-tRC)Or more detailed:
30-38-38-78-58-2-56-56-76-52 (CL-tRCD-tRP-tRAS-tRC-tRFC-tFAW-tRRD_L-tRRD_S-tREFI)XMP and EXPO Profiles
Section titled “XMP and EXPO Profiles”XMP (Intel Extreme Memory Profile)
Section titled “XMP (Intel Extreme Memory Profile)”XMP is an Intel-developed standard for storing pre-validated overclocking profiles in the SPD (Serial Presence Detect) EEPROM on the DIMM. When you enable XMP in BIOS, the motherboard reads the Profile and applies the specified frequency, timings, and voltages.
XMP supports two profiles (Profile 1 and Profile 2), allowing vendors to store a “safe” and an “aggressive” profile. For example:
| Profile | Speed | Timings | Voltage |
|---|---|---|---|
| JEDEC (default) | 4800 MT/s | 40-40-40-77 | 1.1 V |
| XMP Profile 1 | 6000 MT/s | 30-38-38-78 | 1.35 V |
| XMP Profile 2 | 6400 MT/s | 34-45-45-90 | 1.4 V |
EXPO (AMD Extended Profiles for Overclocking)
Section titled “EXPO (AMD Extended Profiles for Overclocking)”EXPO is AMD’s equivalent of XMP. Functionally identical — it stores validated profiles in the SPD Chip. The main difference is branding: EXPO profiles are validated on AMD platforms. In practice, Most EXPO kits work fine on Intel and vice versa, as the memory ICs are the same.
JEDEC Standards
Section titled “JEDEC Standards”JEDEC defines the standard (non-overclocked) operating parameters. Every DDR5 DIMM ships with a JEDEC profile that guarantees operation at the specified speed, timings, and voltage. JEDEC DDR5 Speeds include 4800, 5200, 5600, and 6000 MT/s.
When you do not enable XMP/EXPO, your memory runs at the JEDEC base speed. For high-performance DIMMs, this can mean running at 4800 MT/s instead of the rated 6000+ MT/s. Always enable XMP/EXPO to Get the performance you paid for.
Profile Stability Caveats
Section titled “Profile Stability Caveats”XMP/EXPO profiles are validated by the RAM manufacturer on a reference platform with a single DIMM. Real-world stability depends on:
- Motherboard memory routing quality. Trace length matching, impedance control, and layer stackup vary between boards.
- CPU memory controller quality. The silicon lottery applies to the memory controller too. Some CPUs can drive high-speed memory with two DIMMs populated; others cannot.
- DIMM population. Two DIMMs is harder than one; four DIMMs is harder still. The memory controller must drive twice or four times the electrical load.
- Temperature. DRAM is temperature-sensitive. Higher temperatures require more voltage or relaxed timings.
Channel Architecture
Section titled “Channel Architecture”Single, Dual, and Quad Channel
Section titled “Single, Dual, and Quad Channel”Modern desktop platforms support dual-channel memory. The memory controller has two independent 64-bit channels, each with its own address/command bus and data bus. Dual-channel operation doubles The theoretical peak bandwidth:
Bandwidth = \frac{MT/s \times 8 \mathrm{ bytes \times channels}{1000}| Configuration | DDR5-6000 Bandwidth |
|---|---|
| Single channel | 48.0 GB/s |
| Dual channel | 96.0 GB/s |
| Quad channel (HEDT/server) | 192.0 GB/s |
DIMM Population Rules
Section titled “DIMM Population Rules”For dual-channel operation, populate slots according to the motherboard manual. :
- 2 DIMMs: Slots A2 and B2 (the second slot from each channel, color-coded)
- 4 DIMMs: Slots A2, B2, A1, B1
Populating the wrong slots can result in single-channel operation, halving your bandwidth. Verify With CPU-Z (Windows) or lshw -class memory (Linux).
1R vs 2R DIMMs
Section titled “1R vs 2R DIMMs”DRAM modules can be single-rank (1R) or dual-rank (2R). A rank is a set of DRAM chips that share the Same address/command bus. A 2R DIMM has two independent sets of banks that can be accessed in an Interleaved fashion.
2R DIMMs have higher bank-level parallelism, which means:
- Better performance for random access patterns (more banks to interleave)
- Higher capacity per DIMM
- Harder to overclock (the memory controller drives two ranks instead of one)
For maximum overclocking headroom, 1R DIMMs are preferred. For maximum capacity and mixed-workload Performance, 2R DIMMs are better. The practical difference at the same speed and timings is 3–8% in gaming workloads, favoring 2R.
Memory Frequency vs. Latency Trade-off
Section titled “Memory Frequency vs. Latency Trade-off”The fundamental trade-off in memory tuning is between bandwidth (frequency) and latency (timings). Higher frequency provides more bandwidth but often comes with looser timings, which increases Latency.
Which Matters More?
Section titled “Which Matters More?”The answer depends on the workload:
- Gaming: Latency matters more than bandwidth for most titles. DDR5-6000 CL30 is often faster than DDR5-7200 CL34 in games, despite the lower bandwidth.
- Compression/encoding: Bandwidth matters more. These workloads stream large amounts of data sequentially and benefit from higher transfer rates.
- Scientific computing: Depends on the access pattern. Dense matrix operations benefit from bandwidth; sparse operations benefit from low latency.
- Database workloads: Latency is critical. Each query involves many small random reads.
AMD Zen 4 Memory Sweet Spot
Section titled “AMD Zen 4 Memory Sweet Spot”On AMD Zen 4 (Ryzen 7000 series), the memory controller runs at half the DDR5 frequency (1:2 mode) Up to 6000 MT/s. Above 6000 MT/s, it switches to 1:2.67 mode (UCLK = DDR5 / 2.67), which introduces Additional latency. This makes DDR5-6000 the optimal frequency for Zen 4 in most workloads.
Intel 13th/14th Gen Memory Sweet Spot
Section titled “Intel 13th/14th Gen Memory Sweet Spot”Intel’s memory controller handles DDR5 up to ~7200 MT/s comfortably. The sweet spot is DDR5-6400–6800 CL32-CL34. Beyond 7200 MT/s, stability with two DIMMs becomes increasingly difficult.
Memory Controller Tuning
Section titled “Memory Controller Tuning”Gear Mode (Intel)
Section titled “Gear Mode (Intel)”Intel’s Gear Mode controls the ratio between the memory bus frequency and the memory controller’s Internal clock:
| Gear Mode | Ratio | Frequency Range | Latency Impact |
|---|---|---|---|
| Gear 1 | 1:1 | Up to ~3600 MT/s (DDR4) / ~5600 MT/s (DDR5) | Lowest |
| Gear 2 | 1:2 | Up to ~7200 MT/s (DDR4) / ~8400 MT/s (DDR5) | Moderate increase |
| Gear 4 | 1:4 | Extreme overclocking only | Significant increase |
Gear 1 provides the lowest latency because the memory controller operates at the same frequency as The memory bus. Gear 2 halves the controller frequency, which adds approximately 2–4 ns of latency. For DDR5, most kits above 6000 MT/s require Gear 2.
FCLK (AMD)
Section titled “FCLK (AMD)”On AMD platforms, FCLK (Infinity Fabric Clock) is the clock speed of the Infinity Fabric Interconnect that connects the CPU cores to the memory controller and PCIe controller. FCLK has a Significant impact on performance because it determines the speed of inter-core communication and L3 Cache access.
- Synchronous mode (1:1): FCLK = UCLK = MCLK / 2. Maximum FCLK is 2000–2200 MHz (DDR5-4000 to DDR5-4400 equivalent for Zen 3, or DDR5-6000 on Zen 4 with 1:2 UCLK).
- Asynchronous mode: FCLK can be set independently of UCLK. This allows higher memory frequencies but introduces a desynchronization penalty for fabric-crossing traffic.
On Zen 3, the synchronous 1:1 FCLK:UCLK ratio was critical for performance, limiting effective DDR4 Speed to ~3600 MT/s. On Zen 4, the memory controller architecture changed, making asynchronous Operation less penalizing.
Memory Overclocking Methodology
Section titled “Memory Overclocking Methodology”Step-by-Step Process
Section titled “Step-by-Step Process”Start with XMP/EXPO enabled. This gives you the manufacturer’s validated baseline.
Establish a stability baseline. Run MemTest86 for 4 passes and TestMem5 for 30 minutes at XMP/EXPO settings. If XMP is not stable at two DIMMs, reduce frequency by one step or increase voltage.
Tighten primary timings. Reduce CL by 1 cycle. Test. If stable, reduce tRCD and tRP by 1 each. Test. Continue until unstable, then back off.
Tighten secondary timings. Focus on tFAW (reduce by 2–4 cycles) and tRRD_L (reduce by 1–2 cycles). These have a measurable impact with relatively low risk.
Tertiary timings (advanced). Reduce tRFC (this is the biggest tertiary timing on DDR5) and increase tREFI. These require extended stability testing.
Increase frequency (optional). If timings are tight, try increasing frequency by 200 MT/s. You may need to relax timings slightly to compensate.
Voltage adjustments. If you hit instability, increase VDDQ by 0.05 V increments (up to 1.4 V for daily use on DDR5). For extreme tuning, VDD can go to 1.45 V with adequate cooling.
Voltage Parameters
Section titled “Voltage Parameters”| Voltage | Function | DDR5 Safe Range | DDR5 Extreme Range |
|---|---|---|---|
| VDD | Core DRAM voltage | 1.1–1.35 V | 1.35–1.45 V |
| VDDQ | I/O voltage | 1.1–1.35 V | 1.35–1.45 V |
| VPP | Wordline voltage | 1.8 V (fixed) | Do not adjust |
| VDDIO (CPU side) | CPU memory controller voltage | 1.1–1.35 V | 1.35–1.4 V |
| SA (System Agent) | Uncore voltage (Intel) | 0.9–1.1 V | 1.1–1.25 V |
| VDDP | SoC voltage (AMD) | 0.9–1.0 V | 1.0–1.1 V |
Stability Testing After Changes
Section titled “Stability Testing After Changes”| Test | Duration | What It Catches |
|---|---|---|
| MemTest86 (bootable) | 4+ passes | Basic memory errors, cell-level faults |
| TestMem5 with Anta777 config | 30–60 min | Timing instability, marginal errors |
| Karhu RAM Test | 3–4 cycles | Comprehensive, catches edge cases (paid) |
| y-cruncher (Pi computation) | 15–30 min | Real-world instability under load |
| HCI MemTest | 200%+ coverage | Memory controller stress under Windows |
ECC Memory
Section titled “ECC Memory”How ECC Works
Section titled “How ECC Works”Error-Correcting Code (ECC) memory adds an extra memory chip (or chips) per DIMM that stores parity And syndrome information. For single-bit errors, ECC can detect and correct the error transparently (SEC — Single Error Correction). For multi-bit errors, ECC can detect the error but cannot correct It (DED — Double Error Detection), triggering a machine check exception.
ECC Memory Types
Section titled “ECC Memory Types”| Type | Correction Capability | Overhead |
|---|---|---|
| SEC-DED | Correct 1-bit, detect 2-bit | 8 bits per 64 bits (1 extra chip) |
| Chipkill / x4 SDDC | Correct any 4-bit error in one chip | Higher overhead |
| DDR5 in-band ECC | Correct 1-bit per burst (internal) | No extra pins |
DDR5 introduces “in-band” ECC, where each 128-bit access includes 8 extra ECC bits that allow the DRAM to correct single-bit errors internally. This is separate from traditional ECC — it protects Against bit flips within the DRAM chip itself but does not protect against bus errors or provide the Same level of protection as platform-level ECC.
Performance Impact
Section titled “Performance Impact”ECC memory has a small performance penalty (1–3%) due to the extra read-modify-write cycle for Updates and the latency of error checking. On registered ECC (RDIMM), there is an additional latency From the register buffer. On load-reduced DIMMs (LRDIMM), the latency penalty is larger (~5–10%) but Capacity is significantly higher.
When to Use ECC
Section titled “When to Use ECC”- Servers and workstations with important data: ECC is strongly recommended. The cost premium is small relative to the value of the data.
- ZFS NAS systems: ECC is highly recommended. ZFS relies on data integrity; silent bit flips in memory can propagate to disk and corrupt your pool.
- Gaming and desktop use: ECC is generally unnecessary. Consumer platforms rarely support ECC anyway (Intel Z-series chipsets do not; AMD AM5 does).
Virtual Memory and Swap Tuning
Section titled “Virtual Memory and Swap Tuning”Swappiness
Section titled “Swappiness”The Linux kernel’s vm.swappiness parameter controls the tendency to swap anonymous memory (application data) versus dropping file cache pages. The default value is 60, which is a poor Default for systems with sufficient RAM.
| Swappiness | Behavior |
|---|---|
| 0 | Only swap to avoid OOM. On kernels 3.5+, this is “never swap unless necessary.” |
| 1 | Minimum swapping without fully disabling it. |
| 10 | Prefer keeping anonymous memory in RAM; swap only under significant pressure. |
| 60 | Default. Balanced but swaps too aggressively for modern systems with 16+ GB RAM. |
| 100 | Aggressively swap anonymous memory. |
For desktops with 16 GB or more RAM:
## Check current valuecat /proc/sys/vm/swappiness
## Set to 10 for desktop useecho 10 | sudo tee /proc/sys/vm/swappiness
# Make permanentecho "vm.swappiness=10" | sudo tee -a /etc/sysctl.d/99-swappiness.confTransparent Huge Pages (THP)
Section titled “Transparent Huge Pages (THP)”THP allows the kernel to allocate 2 MB pages instead of the standard 4 KB pages, reducing TLB misses For workloads with large memory footprints. THP is enabled by default (madvise mode on many Distributions, always on some).
# Check THP modecat /sys/kernel/mm/transparent_hugepage/enabled
# Set to madvise (only applications that request it get huge pages)echo madvise | sudo tee /sys/kernel/mm/transparent_hugepage/enabled
# Set to always (kernel aggressively uses huge pages)echo always | sudo tee /sys/kernel/mm/transparent_hugepage/enabledHuge Pages
Section titled “Huge Pages”Static huge pages are pre-allocated at boot time and cannot be swapped out. They are used by Applications like databases and DPDK that require pinned, non-swappable memory.
# Configure 1024 huge pages (each 2 MB = 2 GB total)echo 1024 | sudo tee /proc/sys/vm/nr_hugepages
# Verifygrep -i huge /proc/meminfo
# Persistent configuration: add to kernel parameters# default_hugepagesz=2M hugepagesz=2M hugepages=1024NUMA Memory Policy
Section titled “NUMA Memory Policy”On NUMA systems, you can control memory allocation policies:
# Interleave allocations across all NUMA nodesnumactl --interleave=all ./my_app
# Prefer allocating on node 0, with fallback to node 1numactl --preferred=0 ./my_app
# Bind exclusively to node 0numactl --cpunodebind=0 --membind=0 ./my_appIntuition
Section titled “Intuition”Memory tuning is like organizing a workshop. If your tools (frequently accessed data) are close at hand (in cache), you work faster. If you have to walk to the garage (RAM) or the warehouse (disk), you waste time. Memory tuning ensures your most-used tools are always within reach.
RAM timings are like the speed of a librarian. Lower latency means the librarian finds your book faster. Higher frequency means the librarian can process more requests per second. The best performance comes from a librarian who is both fast and handles many requests.
Common Pitfalls
Section titled “Common Pitfalls”Mixing RAM Kits
Section titled “Mixing RAM Kits”Two identical-looking RAM kits from different production batches can have different memory ICs (e.g., Samsung B-die vs. Micron Rev.E). When mixed, the system must use the timings of the slower Kit, and the memory controller may struggle with the combined electrical load. Always buy a single Kit with the total capacity you need.
Overclocking Without Testing
Section titled “Overclocking Without Testing”A system that boots and runs benchmarks is not necessarily stable. Memory instability can cause Silent data corruption — the system continues running but produces incorrect results. This is Particularly dangerous for ZFS pools, databases, and compilation workloads. Always run MemTest86 and TestMem5 after any timing or frequency change.
Ignoring tRFC on DDR5
Section titled “Ignoring tRFC on DDR5”DDR5 has much higher tRFC values than DDR4 ( 500–700 cycles vs. 300–350 cycles). TRFC Represents dead time where the memory cannot service requests while refreshing. Tightening tRFC is One of the most impactful tertiary timing adjustments on DDR5, but it is also one of the most likely To cause instability if set too aggressively.
Running Four DIMMs at Maximum Speed
Section titled “Running Four DIMMs at Maximum Speed”Populating all four DIMM slots significantly increases the electrical load on the memory controller. Most kits rated for 6000+ MT/s are only validated for two-DIMM configurations. With four DIMMs, you Will likely need to reduce frequency by one or two steps (e.g., from 6000 to 5200 or 5600 MT/s) or Increase voltage. Check your motherboard’s QVL (Qualified Vendor List) for four-DIMM validated Speeds.
Confusing MT/s with MHz
Section titled “Confusing MT/s with MHz”DDR memory speeds are measured in MT/s (mega-transfers per second), not MHz. DDR5-6000 transfers 6000 million times per second, but the actual clock frequency is 3000 MHz because DDR transfers data On both edges of the clock signal (double data rate). When you see “6000 MHz” in a BIOS or review, It means 6000 MT/s.
Neglecting DRAM Cooling
Section titled “Neglecting DRAM Cooling”High-speed DDR5 modules generate significant heat — 5–8 W per DIMM under sustained load. Without Adequate airflow over the DIMMs, temperatures can exceed 60 °C, which forces the memory controller To insert wait states or can cause instability. Ensure your case has intake airflow that passes over The DIMM area, or use aftermarket DRAM heatsinks and fans.
Deep Dive: DDR5 Electrical Characteristics
Section titled “Deep Dive: DDR5 Electrical Characteristics”Signal Integrity
Section titled “Signal Integrity”DDR5 operates at significantly higher speeds than DDR4, which makes signal integrity critical. Key Electrical parameters:
| Parameter | DDR4-3200 | DDR5-4800 | DDR5-6400 |
|---|---|---|---|
| Data Rate | 3200 MT/s | 4800 MT/s | 6400 MT/s |
| VDDQ | 1.2 V | 1.1 V | 1.1 V |
| VPP | 2.5 V | 1.8 V | 1.8 V |
| VREFDQ | 0.6 V | 0.55 V | 0.55 V |
| AC/DC Swing | 340 mV / 250 mV | 300 mV / 250 mV | 300 mV / 250 mV |
| DQS Phase | 90° | 90° | 90° |
Decision Feedback Equalizer (DFE)
Section titled “Decision Feedback Equalizer (DFE)”At DDR5 speeds (4800+ MT/s), the signal degrades significantly over the PCB traces. DDR5 introduces A Decision Feedback Equalizer (DFE) in the memory controller and on the DIMM to compensate for Inter-symbol interference (ISI):
- Transmit DFE (TX DFE): On the memory controller side, compensates for signal degradation on the write path.
- Receive DFE (RX DFE): On the DIMM side, compensates for signal degradation on the read path.
DFE training occurs during system boot (JEDEC training sequence) and can be a source of Compatibility issues — some CPU/memory combinations fail DFE training at high speeds.
Training and Calibration Sequence
Section titled “Training and Calibration Sequence”On boot, the memory controller performs a calibration sequence:
- ZQ Calibration: Calibrates the on-die termination (ODT) resistors by comparing against a precision external resistor (RZQ). Takes approximately 256 clock cycles.
- Read Leveling: Adjusts the DQS read strobe timing to align with the center of the data eye. The controller sweeps the DQS delay and finds the optimal sampling point.
- Write Leveling: Adjusts the DQS write strobe timing from the controller’s perspective.
- VREF Training: Calibrates the reference voltage for the receiver to optimize the data eye opening.
- DFE Training: (DDR5 only) Trains the decision feedback equalizer taps.
This entire sequence takes 1–3 seconds. If any training step fails, the system falls back to a lower Speed or fails to boot.
Memory Controller Architecture
Section titled “Memory Controller Architecture”Intel Memory Controller (12th-14th Gen)
Section titled “Intel Memory Controller (12th-14th Gen)”Intel’s memory controller is integrated into the CPU die and connects to the DDR5 DIMMs via the Processor’s DDR5 interface:
- One memory controller per CPU (not per CCD like AMD).
- Supports 2 channels with 1 DIMM per channel for DDR5-6400+ stable operation.
- Gear mode: Controls the ratio between the memory bus and the internal clock. Gear 2 (1:2) is required above DDR5-5600.
The Intel memory controller is generally more forgiving than AMD’s when it comes to running two DIMMs at high speeds. Most Intel 13th/14th Gen systems can run two DIMMs at DDR5-6800 with relaxed Timings.
AMD Memory Controller (Zen 4)
Section titled “AMD Memory Controller (Zen 4)”AMD’s Zen 4 memory controller is a significant improvement over Zen 3:
- 1:2 UCLK ratio at DDR5-6000, providing optimal latency.
- Up to DDR5-5200 in 1:1 UCLK mode (FCLK = UCLK = MCLK/2).
- Infinity Fabric clock can run asynchronously at higher speeds, reducing the penalty of 1:2.67 mode.
The Zen 4 memory controller’s sweet spot is DDR5-6000 CL30. Going above this requires 1:2.67 mode, Which adds approximately 3–5 ns of latency.
Advanced Timing Tuning
Section titled “Advanced Timing Tuning”Secondary Timing Tuning Process
Section titled “Secondary Timing Tuning Process”After tightening primary timings, secondary timings provide the next level of optimization:
- tFAW (Four Activate Window): Start at the JEDEC default and reduce by 2 cycles at a time. For dual-rank DDR5, tFAW is 24–32. Try reducing to 20–24.
- Lower tFAW allows more activate commands in a given window, improving row access parallelism.
- Too low causes data corruption because the DRAM cells do not have enough time to settle.
- tRRD_S and tRRD_L:
- tRRD_S (Same Bank Group): Start at 4, try reducing to 3.
- tRRD_L (Different Bank Group): Start at 6, try reducing to 4.
- These affect the time between activating different rows. Lower values improve interleaved access performance.
tCWL (CAS Write Latency): CL - 1 or CL. Try setting to CL - 1 if it is currently at CL. Write latency has less impact on most workloads than read latency.
tWR (Write Recovery Time): Try reducing by 1 cycle. This is the time after a write before the row can be precharged. Related to tRTP (Read to Precharge).
Tertiary Timing Exploration
Section titled “Tertiary Timing Exploration”Tertiary timings are risky to tune but can provide measurable improvements:
- tRFC (Refresh Cycle Time): This is the biggest tertiary timing on DDR5. Default values are often very conservative. Try reducing by 20–40 cycles at a time.
- DDR5-6000 CL30 has tRFC around 500–550. Many kits can run at 460–480.
- Reducing tRFC directly improves performance because the DRAM is unavailable for a shorter period during refreshes.
- tREFI (Refresh Interval): Default is 31200 for DDR5 (at normal temperature). Increasing tREFI delays refresh cycles, improving performance but reducing data retention margin.
- Try increasing to 62400 or 93600.
- At higher tREFI values, the DRAM may lose data if the ambient temperature is high or if there are long periods without access.
tRDWR (Read to Write Turnaround): Default is 5–7 cycles. Try reducing by 1.
tWRRD (Write to Read Turnaround): Default is 6–8 cycles. Try reducing by 1.
Memory Stress Testing After Tertiary Timing Changes
Section titled “Memory Stress Testing After Tertiary Timing Changes”Tertiary timing instability is often intermittent and may not appear in short tests:
- Run TestMem5 with Anta777 config for 2+ hours.
- Run Karhu RAM Test for 4+ cycles (if available).
- Run y-cruncher for 1+ hour.
- Run MemTest86 for 8+ passes.
- Use the system normally for 24 hours and check for any unexpected crashes or corruption.
Virtual Memory Deep Dive
Section titled “Virtual Memory Deep Dive”Transparent Huge Pages Internals
Section titled “Transparent Huge Pages Internals”THP works by the kernel’s khugepaged daemon scanning process memory and collapsing contiguous Standard (4 KB) pages into huge pages (2 MB). This process involves:
- Scanning:
khugepagedperiodically scans process address spaces looking for contiguous 4 KB pages that could be collapsed into a single 2 MB page. - Copying: When eligible pages are found,
khugepagedallocates a 2 MB page, copies the data from the constituent 4 KB pages, and updates the page tables. - Collapsing: The original 4 KB pages are freed and replaced with the single 2 MB page.
This process consumes CPU and memory bandwidth. Under memory pressure, the cost of the collapsing Operation can cause latency spikes.
Huge Pages Configuration
Section titled “Huge Pages Configuration”# Check current huge page settingscat /proc/meminfo | grep -i huge
# Allocate 1024 huge pages at boot (2 GB total)# Add to kernel parameters:# default_hugepagesz=2M hugepagesz=2M hugepages=1024
# Or allocate dynamicallyecho 1024 | sudo tee /proc/sys/vm/nr_hugepages
# Verify allocationgrep -i huge /proc/meminfo
# Configure libhugetlbfs for transparent usage# LD_PRELOAD=/usr/lib64/libhugetlbfs.soSwap File vs. Swap Partition
Section titled “Swap File vs. Swap Partition”| Feature | Swap File | Swap Partition |
|---|---|---|
| Resizable | Yes (fallocate, truncate) | No (requires partitioning tool) |
| Location flexibility | Any filesystem (except ZFS) | Dedicated partition |
| Multiple | Yes (multiple swap files) | No (one per partition) |
| Performance | Slightly lower (filesystem overhead) | Slightly higher (raw device) |
| Recommended for | Modern Linux (kernel 5.0+) | Legacy systems |
# Create a swap filesudo fallocate -l 8G /swapfilesudo chmod 600 /swapfilesudo mkswap /swapfilesudo swapon /swapfile
# Make permanentecho '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
# Verifyswapon --showfree -hCross-References
Section titled “Cross-References”- CPU Fundamentals - How memory controllers and IMC settings interact with CPU performance
- Stress Testing - How memory stress tests validate XMP/EXPO profile stability
- Undervolting and Overclocking - How memory voltage and timing adjustments affect system stability