DEV Community

mmllllzcn
mmllllzcn

Posted on

TIL: Why GBase Database Deployment Often Requires Disabling Transparent Huge Pages

During a pre-install check on a GBase Database(GBase 8a MPP Cluster) environment running Kylin V10, I found a familiar configuration issue: Transparent Huge Pages (THP) was still set to always.

The services could start, but bulk-load performance was inconsistent. With three machines configured differently, the slowest node became the first place to investigate.

THP was one potential factor worth checking before spending hours troubleshooting database performance.

What Is Transparent Huge Pages?

Linux Transparent Huge Pages allows the kernel to use larger memory pages, commonly 2 MB instead of 4 KB, without requiring applications to manage huge pages explicitly.

The potential benefit is fewer Translation Lookaside Buffer (TLB) misses. However, THP can also introduce memory compaction, allocation latency, and background activity that affect latency-sensitive workloads.

For analytical databases such as GBase Database(GBase 8a), large memory allocations may occur during operations such as hash aggregation, sorting, and bulk loading. Depending on the kernel and workload, THP-related activity can contribute to performance variability.

This does not mean THP always slows down a database. It means the setting should be validated against the database's deployment requirements and workload.

1. Check the Current THP Configuration

Inspect the active settings:

cat /sys/kernel/mm/transparent_hugepage/enabled
cat /sys/kernel/mm/transparent_hugepage/defrag
Enter fullscreen mode Exit fullscreen mode

Example output:

always madvise [never]
Enter fullscreen mode Exit fullscreen mode

The value inside square brackets is the active setting. In this example, THP is set to never.

If you see:

[always] madvise never
Enter fullscreen mode Exit fullscreen mode

THP is configured to always.

Check whether huge pages are being used during a workload:

grep -E 'AnonHugePages|ShmemHugePages|FileHugePages' /proc/meminfo
Enter fullscreen mode Exit fullscreen mode

Compare the values before and during bulk loading. AnonHugePages can help indicate anonymous memory backed by huge pages, but it does not independently prove that THP caused a performance issue.

2. Disable THP Temporarily for Validation

If the GBase Database installation guide for your release recommends disabling THP, you can apply the change at runtime:

echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo never > /sys/kernel/mm/transparent_hugepage/defrag
Enter fullscreen mode Exit fullscreen mode

These commands require root privileges. The settings generally do not survive a reboot.

After applying the change, verify the active values again:

cat /sys/kernel/mm/transparent_hugepage/enabled
cat /sys/kernel/mm/transparent_hugepage/defrag
Enter fullscreen mode Exit fullscreen mode

Then compare the database's behavior under the same workload and conditions. Check load duration, latency variation, memory utilization, and relevant system logs rather than assuming that a configuration change guarantees a performance improvement.

3. Make the Configuration Persistent

For a persistent configuration, use the method supported by your Linux distribution and kernel.

Some environments support systemd services, boot scripts, kernel command-line parameters, or tuned profiles. Their behavior and syntax vary.

For example, on a system where /etc/rc.d/rc.local is supported and executed during boot, the following commands may be used:

# Add to /etc/rc.d/rc.local
echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo never > /sys/kernel/mm/transparent_hugepage/defrag
Enter fullscreen mode Exit fullscreen mode

If necessary, make the script executable:

chmod +x /etc/rc.d/rc.local
Enter fullscreen mode Exit fullscreen mode

Do not assume this method works on every distribution. Validate the boot mechanism and check whether another service or tuned profile overrides the setting.

After rebooting, confirm the active configuration again. Repeat the check after changing system profiles or applying OS updates.

4. Validate Every Node in the GBase Database Cluster

A configuration that is correct on one machine may be wrong on another.

For a multi-node GBase Database deployment, include THP validation in the pre-install checklist and provisioning automation.

At minimum, check:

  • Active THP settings on every node.
  • Consistency of kernel and OS versions.
  • Whether system profiles override the setting.
  • Memory behavior during representative workloads.
  • Database-specific recommendations for the installed release.

Explicit Huge Pages are a separate configuration choice. They require appropriate memory reservation and database configuration, so do not enable them without checking the product documentation and operating system requirements.

Final Takeaway

Transparent Huge Pages is a small OS setting with potentially significant implications for database performance consistency.

For GBase Database(GBase 8a MPP Cluster), the practical lesson is to validate THP before installation, keep cluster nodes consistent, and measure the impact under a representative workload.

A repeatable pre-install check is more reliable than discovering configuration differences during production troubleshooting.

TIL question: Do you disable THP by default for database servers, or do you benchmark it separately for each workload?

Keywords: GBase Database, GBase 8a, Transparent Huge Pages, THP Linux, database performance tuning, Kylin V10, Linux pre-install checks

Top comments (0)