Skip to content

feat(tuned): ensure CPUs are giving it their all#2069

Merged
hunleyd merged 9 commits intodevelopfrom
INDATA-475
Feb 27, 2026
Merged

feat(tuned): ensure CPUs are giving it their all#2069
hunleyd merged 9 commits intodevelopfrom
INDATA-475

Conversation

@hunleyd
Copy link
Contributor

@hunleyd hunleyd commented Feb 26, 2026

This commit enhances the custom tuned profile for PostgreSQL by forcing the CPU into a maximum performance
state. These changes are critical for maintaining consistent low-latency database performance.

Key Changes and Benefits:

  • CPU Governor & Energy Bias: Switched to 'performance' mode. This prevents the kernel from scaling down CPU frequencies during periods of lower activity, eliminating the "ramp-up" latency when a burst of queries arrives.
  • Min Performance Percentage: Fixed at 100% to ensure the processor stays at its maximum base frequency, reducing jitter in query execution times.

(ripgrep of all Supa repos for the 3 tunables herein returned nothing, so no chance of clobbering the setting)

This commit enhances the custom `tuned` profile for PostgreSQL by
forcing the CPU into a maximum performance
state. These changes are critical for maintaining consistent low-latency
database performance.

Key Changes and Benefits:

- CPU Governor & Energy Bias: Switched to 'performance' mode. This prevents
the kernel from scaling down CPU frequencies during periods of lower
activity, eliminating the "ramp-up" latency when a burst of queries
arrives.
- Min Performance Percentage: Fixed at 100% to ensure the processor stays
at its maximum base frequency, reducing jitter in query execution times.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Enhances the Ansible-managed custom tuned PostgreSQL profile to keep CPUs in a maximum-performance state, aiming to reduce latency/jitter for bursty database workloads.

Changes:

  • Ensures the “Create a tuned profile” task runs with privilege escalation (become: true).
  • Renames the THP task for clearer intent and standardizes loop item formatting.
  • Adds a new task intended to configure CPU performance-related tuned settings in /etc/tuned/postgresql/tuned.conf.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

hunleyd and others added 6 commits February 26, 2026 19:12
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…-475

* 'INDATA-475' of github.com:supabase/postgres:
  Update ansible/tasks/setup-tuned.yml
  Update ansible/tasks/setup-tuned.yml
@hunleyd
Copy link
Contributor Author

hunleyd commented Feb 27, 2026

============================================================
Test Summary
============================================================

ENGINE          RESULT
------          ------
15              PASSED (435s)
17              PASSED (352s)
17-oriole       PASSED (716s)

============================================================
Total: 3 | Passed: 3 | Failed: 0
============================================================

[INFO] Postgres commit: e568cea207339c1243b920512f4dfb738ae4778a
[INFO] Cache location: /Users/jimchancojr/.cache/supadev/postgres/e568cea207339c1243b920512f4dfb738ae4778a
[SUCCESS] All tests passed!

@hunleyd hunleyd marked this pull request as ready for review February 27, 2026 19:51
@hunleyd hunleyd requested review from a team as code owners February 27, 2026 19:51
@samrose samrose self-requested a review February 27, 2026 20:19
Copy link
Collaborator

@samrose samrose left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Critical Issues (fix before merge)

  1. Typo: min_pef_pct → min_perf_pct (setup-tuned.yml:79)

The option name is misspelled — missing the r in perf. The tuned daemon will silently write the malformed key and ignore it, meaning the CPU minimum P-state floor will
never be enforced despite the intent. This is the most impactful bug.

Wrong:

  • { section: 'cpu', option: 'min_pef_pct', value: '100' }

Correct:

  • { section: 'cpu', option: 'min_perf_pct', value: '100' }
  1. Symlink creation will fail on existing hosts (setup-tuned.yml:23-31)

If a host was provisioned before this branch (where /etc/tuned/postgresql was a directory), the state: 'link' task will fail with [Errno 17] File exists. Ansible won't
remove an existing directory to create a symlink in its place. This is lower risk in an AMI build workflow (fresh builds), but needs a force: true or pre-removal task for
safe re-application.


Important Issues

  1. ARM/Graviton instances silently ignore energy_perf_bias and P-state settings: these are Intel-only controls. Consider a when: platform == 'amd64' guard or
    documentation.

  2. tuned-adm profile postgresql always reports changed: add changed_when: false since activating an already-active profile is a no-op.

  3. Unconditional state: 'restarted' on tuned service:: safe in AMI builds, but risky if the playbook is ever re-applied to a live production instance (causes a brief
    performance regression window).

@hunleyd
Copy link
Contributor Author

hunleyd commented Feb 27, 2026

  1. Unconditional state: 'restarted' on tuned service:: safe in AMI builds, but risky if the playbook is ever re-applied to a live production instance (causes a brief
    performance regression window).

i think this is acceptable as that's how we currently run (w/o optimizations) and we definitely want any new updates to the profile to be applied, which we wouldn't get with started.

…-475

* 'INDATA-475' of github.com:supabase/postgres:
  feat: add `supabase_privileged_role` (#2040)
@hunleyd hunleyd enabled auto-merge February 27, 2026 20:56
@hunleyd hunleyd added this pull request to the merge queue Feb 27, 2026
Merged via the queue into develop with commit f34f6cb Feb 27, 2026
37 checks passed
@hunleyd hunleyd deleted the INDATA-475 branch February 27, 2026 22:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants