WorkstationsLatency and performancereference
GPU voltage-frequency curve control without Afterburner
vfctl is a Go CLI that reads and writes NVIDIA GPU voltage-frequency curves directly via NVAPI, replacing MSI Afterburner’s curve editor. Built after Afterburner’s editor repeatedly produced broken curves - notch artifacts at selection boundaries, temperature-stale baselines, and unexpected whole-curve shifts1 - on an RTX 5090 FE.
Curve struct layouts are from the PenguinBurner reverse-engineering effort2, cross-checked against the LACT issue #936 discovery3, the public NVIDIA nvapi header4, and verified via ctypes. Telemetry structs are from nvapi-rs5, nvapi-sys6, and NVIDIA’s official open-source NVAPI reference7. The write path is verified end-to-end on live silicon: a single-point selftest writes +15 MHz, reads it back, and restores. Telemetry (clock, voltage, utilisation, temperature, power) is verified across full gaming sessions. Measured on a single RTX 5090 FE with driver 610.88; the curve interfaces are undocumented and could change between driver releases.
- Curve write, telemetry, persistence and automated stability search in one static binary, replacing Afterburner for undervolting.
- Since v0.6 vfctl also sets the memory offset and the power limit through P-states 2.0 (
pstates,mem,selftest-mem,power). On the 5090 any P-states 2.0 write zeroes the VF curve, somemsaves the curve first and restores and re-verifies it after. - Writes are read-modify-write via
ClkVfPointsSetControl, confirmed by selftest on the card. - Telemetry covers clock, voltage, utilisation, temperature and live power draw, logged as CSV with a voltage histogram summary.
live --chartandlive --svgplot stock vs applied curve with the current operating point.- A logon task runs
vfctl hold, which applies the curve and re-applies it whenever a driver reset wipes the offsets. It reacts to driver events instead of polling. - On Blackwell the curve sets the frequency ceiling per voltage, and the DVFS governor picks where the card sits.
- Since v0.4.0 vfctl also writes the fan curves into the motherboard’s Nuvoton NCT6799D, which then runs them with no software in the loop. That replaced FanControl, whose once-a-second polling cost an 8 kHz mouse dozens of missed polls a minute; most of that cost was the NVAPI GPU temperature read.
Which do I pick
Section titled “Which do I pick”| Job | Command | What it replaces |
|---|---|---|
| Undervolting a card, with every write read back before it is trusted | set to write the curve, persist to install the logon task, hold to re-apply it when the driver reloads | Afterburner’s curve editor, whose notch artifacts at selection boundaries, temperature-stale baselines and whole-curve shifts1 this was built to escape; a logon-only set also cannot see a driver reinstall |
| Memory offset or power limit on P-states 2.0 | pstates for the table, mem for the P0 memory delta, selftest-mem for the write path, power for the policy limit | Afterburner’s memory slider and power limit controls, with VF curve writes kept separate |
| Fan curves that run with no software in the loop | hold writes the fitted curves into the NCT6799D at logon and re-reads them on its safety check; vfctl fan restore undoes it | FanControl, whose once-a-second sensor polling cost an 8 kHz mouse 54 missed polls a minute, most of it the NVAPI GPU temperature read |
| A live plot of stock vs applied curve | live --chart in the terminal, live --svg PATH for a saved plot | reading raw offsets and reconstructing the curve by hand |
| A session’s telemetry, or an automated search for the stability cliff | watch for the CSV and the per-voltage histogram, watch --limits for perf-limit flags, test for the TDR step-down loop | a second tool: both ship in the same static binary as the curve write |
Architecture
Section titled “Architecture”| Package | What it owns | Key detail |
|---|---|---|
internal/vfcurve | Afterburner blob parse/encode, generation, validation | 12-byte header, 127 points |
internal/curve | Live-curve math: BuildOffsets, VerifyOffsets, ApplyCurve | bounds guard, read-back verify |
internal/testloop | TDR-loop logic: Classify, StepFreq, ParseTDRCount | 100% coverage |
internal/profile | Afterburner .cfg INI read/write | legacy import path |
internal/task | Task Scheduler XML for persist | no 72h limit, restart on failure |
internal/nvapi | nvapi64.dll syscall layer | curve writes, P-states 2.0 (curve saved and restored around each write), telemetry reads |
internal/forensics | heartbeat file, crash records, event-log parsing for hold | no NVAPI calls |
internal/drvevents | System event log subscription for hold | TDR (4101) and driver install (UserPnp 20003) |
internal/sio | Nuvoton NCT6799D access over a two-method port interface | tested against a simulated chip |
internal/pawnio | PawnIO driver binding, embedded signed LpcIO module | shared ISA-bus mutex |
internal/fancurve | FanControl curve import, 4-point chip fit | pure maths |
internal/vfplot | live curve plots | stock vs applied curve, profile cap, current operating point |
cmd/vfctl | CLI dispatch | curve, P-states, hold, fan, telemetry, and crash commands |
Built partly by a self-correcting loop on a local Gemma 4 26B model - the internal/curve and internal/testloop extractions converged in one iteration each against a go test sensor, with human review catching a dropped sentinel guard the tests missed.
The curve write path
Section titled “The curve write path”Three bugs separated the first attempt from a working write, and each was caught only by a stricter verification step than the last:
- A 4-byte struct offset. The control struct’s points start at 0x44; the 0x48 came from a read-only PoC that never exercised a write.
- Mixed struct generations. The status read used a 128-point layout while the control write used 255 points - different index spaces, so “point 72” in the read wasn’t “point 72” in the write.
- A fresh buffer instead of read-modify-write. The driver silently ignores writes to points whose
type_field doesn’t match what it returned. A zeroed buffer writes nothing that sticks.
Writes land when GetControl fills the full table (preserving type_/rsvd), one freq_offset_kHz is modified, and SetControl writes the whole table back. vfctl then reads the point back and treats a write that does not read back as an error.
A fourth bug was in the read path. The status struct’s freq_kHz (+4) is the nominal frequency (base + applied offset), not the base. The true base is vf_tuple_base.freq_kHz (+12). Using the nominal double-counts offsets on any non-stock card. This is why Afterburner profiles “mutate” after apply - the stored frequencies are a temperature-time snapshot, and only the offsets are real.
Telemetry
Section titled “Telemetry”watch samples clock, voltage, utilisation, temperature, and power every interval, logs CSV, and prints a per-voltage histogram on exit. Full-session data from The Finals on an undervolted 5090:
| Metric | Menu | Full load |
|---|---|---|
| Core clock | 2415 MHz | 2433 avg / 2497 max |
| Voltage | 880-885 mV | 930-935 mV (95.7% of time) |
| Utilisation | 13-17% | 72% avg / 99% peaks |
| Temperature | 45C | 57 avg / 61 max |
| Power | 31W | 76W avg / 103W max |
The card sits at 930 mV with the curve targeting 860 because Blackwell’s DVFS governor adds voltage margin under sustained load, independent of the curve. Power (103W max of 575W) and temperature (61C) ruled out both limiters. The voltage step happens the instant utilisation crosses ~85%, before power or clock change, so it tracks how long the load has run rather than how much it asks for.
The cost of that margin is ~5W. The heat goal (“stock perf or better, lowest possible”) was already met: 2433 MHz avg at 76W average on a 575W card.
NVAPI interface reference
Section titled “NVAPI interface reference”All accessed via nvapi_QueryInterface(function_id) on nvapi64.dll. Version field: (version << 16) | struct_size.
Curve (undocumented, verified working)
Section titled “Curve (undocumented, verified working)”| ID | Name | Struct | Notes |
|---|---|---|---|
0x507B4B59 | ClkVfPointsGetInfo | InfoV1, 0x182C | active mask + per-point type/voltage_based |
0x21537AD4 | ClkVfPointsGetStatus | StatusV3, 0x15B0C | 255 pts x 348B at 0x68; base at +12, nominal at +4 |
0x23F1B133 | ClkVfPointsGetControl | ControlV1, 0x2420 | 255 pts x 36B at 0x44; offset at +20 |
0x0733E009 | ClkVfPointsSetControl | ControlV1, 0x2420 | read-modify-write ONLY |
Only points with info-struct type==0 && voltage_based==1 are editable core points - the 255-point buffer also carries memory/other clock domains, and writing those offsets corrupts them.
Telemetry (documented public APIs)
Section titled “Telemetry (documented public APIs)”| ID | Name | Reads |
|---|---|---|
0xDCB616C3 | GetAllClockFrequencies | current core/memory clocks (kHz) |
0x60DED2ED | GetDynamicPstatesInfoEx | utilization % (domain 0) |
0xE3640A56 | GetThermalSettings | temperature - 3-arg call (gpu, sensorIndex, struct) |
0xEDCF624E | ClientPowerTopologyGetStatus | live power draw |
0x465F9BCF | ClientVoltRailsGetStatus | voltage (uV at +0x28) |
ClientPowerPoliciesGetStatus (0x70916171) is one name away from ClientPowerTopologyGetStatus and returns the power-limit policy (frozen ~100%), not live draw. The symptom is a power reading pinned at exactly 100.0 W that never moves.
Memory offset and power limit (P-states 2.0)
Section titled “Memory offset and power limit (P-states 2.0)”vfctl pstates [--json] dumps the table. vfctl mem [--offset MHZ|--reset], vfctl selftest-mem, and vfctl power [--limit PCT] use the same P-states 2.0 path.
Measured on an RTX 5090 FE with driver 617.42 on 2026-10-28:
| Finding | measured: |
|---|---|
NvAPI_GPU_GetPstates20 accepts struct version 3; only P0 is editable | pstates table read |
| P0 delta ranges: graphics -1000..+1000 MHz, memory -1000..+3000 MHz; video, P1, P3, P5 and P8 read-only | pstates table read |
| Memory clock per P-state: P0 14001, P1 13801, P3 7001, P5 810, P8 405 MHz | pstates table read |
| The memory offset adds 1:1 to the reported clock: idle P1 13801 + 200 = 14001 MHz. An old Afterburner profile with memory +2000 read 15801 MHz, which is 13801 + 2000, not the stock clock | mem --offset 200 before/after |
| The card exposes no base-voltage entry, so a voltage offset is not available; undervolting stays on the VF curve | pstates table read |
Any NvAPI_GPU_SetPstates20 write zeroes every VF-curve offset, even a memory delta of 0 to 0 (+892 MHz at 900 mV read +0 after) | VF offsets read before and after |
A P0 graphics delta replaces every VF point offset with that one flat value (+892 became +15 on all points), so core refuses while a curve is applied unless --force | VF offsets read before and after |
With the save-and-restore in place, selftest-mem, mem --offset 200 and mem --reset leave the curve unchanged | VF offsets read after each step |
Power limit range 69.6% to 104.3% (default 100%); power --limit writes, reads back, and leaves the curve alone | power read, write and read-back |
The undervolt algorithm
Section titled “The undervolt algorithm”Stock below the ramp start, linear ramp to the target frequency at the target voltage, flat above. Offsets are computed against the live base (vf_tuple_base), so the result is temperature-correct at apply time:
offset = target_freq - base_freq_at_voltageCurve view is vfctl live --chart in the terminal or vfctl live --svg PATH for a saved file. It shows stock vs applied curve, the profile cap, and the current operating point.
NVIDIA snaps frequencies to 15 MHz steps. A bounds guard rejects values outside sane envelopes (the catastrophic-typo check: 27970 instead of 2797). Every write is verified by read-back within one step, and set self-cleans stale offsets below the ramp region so switching curves never stacks.
Persistence: offsets do not survive a driver reload
Section titled “Persistence: offsets do not survive a driver reload”The offsets live in driver memory. A reboot clears them, and so does any driver reload - including a driver reinstall by the NVIDIA installer while the desktop is running. On 2026-10-08 an installer run reinstalled nvlddmkm mid-session and the card went back to the stock curve with nothing signalling the process that had set it; the original logon-only set task never noticed.
vfctl hold closes that gap. It applies the curve, then checks it only when the driver may have reset it: it subscribes to the System event log for a TDR (Event 4101) or a driver install (Event 20003 from UserPnp, which the 2026-10-08 reinstall logged for nvlddmkm) and checks 10 s after one fires. A safety check every 15 minutes covers anything the log misses and is skipped while a fullscreen game is in front. A GPU device restart (pnputil /restart-device, which IRQ-affinity tools use to apply a pin) also reloads the driver and zeroes the curve, but on this box it logs nothing in the System or Kernel-PnP logs, so since v0.6.2 hold also registers for Plug and Play arrivals of the display adapter interface (CM_Register_Notification) and treats an NVIDIA arrival like a TDR: measured, the arrival reached hold 1 s after the restart and the curve was back 11 s later. Two traps on the way: the notification callback receives 32-bit arguments in 64-bit slots, and using the event size unmasked crashed hold with an access violation; and after one restart the device is left pending a reboot, so a second restart fails while pnputil still exits 0. The first version polled every 15 s, then every 30 s; seven days of its log showed the poll catching drift once, 30 s after startup, so v0.3.0 moved to events. Each check opens a fresh NVAPI session, compares the offsets with what hold last wrote, and re-applies on drift. After 20 failed checks in a row it exits non-zero so Task Scheduler restarts it with a freshly loaded nvapi64.dll.
persist --profile installs the binary and a machine profile under %ProgramFiles% (the task runs elevated, so neither may sit in a user-writable folder) and registers the task without the default 72-hour execution limit. The profile is a JSON file kept in the repo with the undervolt and fan settings, so changing a setting means editing the file and running persist again. Verified live: a fake Event 4101 written to the System log produced a check that found the curve intact, and resetting the card to stock followed by another fake Event 4101 got the curve re-applied (63 points verified).
Crash forensics
Section titled “Crash forensics”Since v0.6.1 hold writes a small heartbeat file after every check and on every 15-minute tick while it is paused for a game: the target V/F, whether the curve checked clean, whether it was paused and for which exe, and the last apply time. The paused ticks make no NVAPI call. When hold finds the curve reset it appends one crash record per episode, with the cause read from the System log (TDR Event 4101, driver install UserPnp 20003, otherwise unknown) and any new crash dumps. At startup it looks for a Kernel-Power 41 newer than the last heartbeat and records it with the Application Error 1000 and WER 1001 events around it. vfctl crashes lists the records. A one-second telemetry history was left out on purpose: it would mean polling NVAPI during games, which the mouse-poll measurements below show is not free. One gotcha when shelling out from Go: Windows PowerShell 5.1 Get-WinEvent -ErrorAction SilentlyContinue exits 1 with no output when nothing matches, so exit 1 with empty output has to be read as “no events”.
Fan curves on the motherboard chip
Section titled “Fan curves on the motherboard chip”FanControl reads every enabled sensor through LibreHardwareMonitor once a second and rewrites each fan’s duty in manual mode every tick. On this machine (ASUS ROG STRIX X670E-I, whose fan headers hang off a Nuvoton NCT6799D Super I/O) that polling showed up as missed polls on an 8 kHz mouse. The chip can run a fan curve itself in its SmartFan IV mode, which is how the BIOS Q-Fan curves already work, so vfctl writes the curves once and leaves the chip to run them.
How it works:
- Chip access goes through PawnIO8, the signed kernel driver FanControl and LibreHardwareMonitor already install, using its signed
LpcIOmodule9 embedded in vfctl. Every transaction holds the sharedGlobal\Access_ISABUS.HTP.Methodmutex those tools use, and vfctl refuses to touch the chip while FanControl runs. - Each FanControl curve (10-13 points) is fitted to the chip’s 4 points plus a full-speed temperature. The fitter tries every 4-point subset and keeps the one with the smallest worst-case duty error: 2.2, 3.7 and 6.4 percentage points for the three curves here.
- Before the first write vfctl saves the BIOS register values, and
vfctl fan restoreputs them back. Every write is read back. vfctl never puts a fan in manual mode, so if it dies the chip keeps running the last curve. holdwrites the curves at logon and re-reads them on its 15-minute safety check. Between checks it makes no fan-side calls.
Register addresses come from the Linux nct6775 driver10 and the NCT6796D datasheet11 (Nuvoton publishes no NCT6799D datasheet). Several facts only showed up on the hardware:
| Finding | How it was checked |
|---|---|
PawnIO’s ioctl_find_bars returns 0x80070490 (not found) unless the chip is already in extended-function mode, because it reads the chip id first | measured: first run failed; the module source confirms the order9 |
The BIOS runs the CPU and chassis channels on source 28, the AMD CPU temperature over SB-TSI (register 0x4F4), not on the PECI or CPUTIN sources | measured: register dump; rose 50 -> 66 C under a 30 s all-core load |
Registers 0x073-0x07D show each fan channel’s current input temperature, not fixed sensors, so LibreHardwareMonitor’s names for them (PECI_0, CPUTIN, SYSTIN, AUXTIN0-2) do not fit this board | measured: 0x073 read 0 when channel 0 moved to an unset source, then the value written into that source |
| SmartFan IV interpolates linearly between the 4 points | measured: three channels within one duty step of the linear value |
Index 0x03 is the step-up time and 0x04 the step-down time (some sources swap them). The ASUS BIOS leaves both at 0 and the duty-per-step register 0x66 at 0, so writing a non-zero step time freezes the output | measured: with step times written, the chip’s computed target (0x0B) was right but two outputs never moved; keeping the BIOS 0/0 fixed it. Register meanings from the datasheet11 |
| Source 31 reads the channel’s software-writable Virtual1 register, so a program can feed the chip an outside temperature | measured: monitor slot and output followed the written value |
| The ASUS embedded controller does not rewrite the registers | measured: unchanged 7 minutes later and across restarts of hold |
What sensor polling costs an 8 kHz mouse
Section titled “What sensor polling costs an 8 kHz mouse”MousePlotter12 recordings of a Nuvoton M483 wired mouse at 8 kHz showed the missed polls that started this work. Each run below counts gaps over 0.4 ms per minute while the mouse was moving. The runs are 30-65 s each, and two that should match (the “curves on the chip” and “chip read only” rows) differ by 2x, so treat a single row as plus or minus half. The direction held across every run.
| Configuration | Gaps over 0.4 ms per minute |
|---|---|
| FanControl running (Motherboard, CPU and NVAPI sources) | 54 |
| FanControl closed | 11 |
| vfctl curves on the chip, nothing polling | 15 |
hold reading only the fan chip every 5 s | 7 |
hold reading the GPU temperature through NVAPI every 5 s | 49-60 |
hold reading the GPU temperature every 60 s | 36 |
How it was checked: MousePlotter recordings of the M483 wired mouse on the RTX 5090 FE with driver 610.88, one configuration per run, mouse moving throughout.
A chip register read through PawnIO (p99 0.53 ms of wall time) cost nothing measurable. The NVAPI GPU temperature read cost most of FanControl’s overhead, whether the session stayed open or was opened per read, and the gaps came with the stall signature of a system-wide pause: MousePlotter lost its kernel timestamps for them. That runs against the usual view that on-die GPU temperature reads are cheap, at “a few microseconds” of CPU time13; on this RTX 5090 the CPU time may be small, but the stall it causes is not. Why the driver stalls is not established.
So the chassis fan, which FanControl drove from the higher of the CPU and GPU curves, now follows the CPU curve on the chip. vfctl can still drive a channel from max(CPU, GPU) by writing the GPU temperature into the channel’s Virtual1 register at a set interval; the profile leaves that off.
Stability testing methodology
Section titled “Stability testing methodology”- Run the selftest first: write +15 MHz to one point, read back, restore. This proves the write path before anything else depends on it.
- Test in a game: The Finals (Unreal Engine 5, transient-heavy).
- On TDR (Windows Event 4101), step down -15 MHz and retest;
vfctl testautomates this loop. - Watch the histogram, and judge the undervolt by where the card sits under load rather than by the target you set.
On driver 610.88, the stability cliff for a 5090 FE is exactly one 15 MHz step wide: 2812 @ 900 mV is stable, 2827 (the old-driver stable curve) crashes.
Known limitations
Section titled “Known limitations”- Writes require Administrator (error -137,
NVAPI_INVALID_USER_PRIVILEGE); reads work unelevated - The curve does not pin the operating voltage; the DVFS governor adds margin under sustained load. Forcing lower needs a declining curve, which is notch territory
- The undocumented curve interfaces may change between driver releases
- Windows only (driver 610.88). The Linux driver ships
libnvidia-api.so.1with the samenvapi_QueryInterfaceentry point and VF function IDs (LACT’s VF curve editor uses them14), so a Linux backend is a port of the call layer, not new reverse engineering - Not yet measured: memory clock under game load with an offset
- Not yet measured:
watch --limitsinside a GPU-bound game - GPU fan control is out of scope: manual % clamps to 30% minimum and 0 RPM is vBIOS-auto only; the card’s own curve stays in charge
- Motherboard fan control covers the Nuvoton NCT6799D only, verified on one ASUS board; other Super I/O chips need their own register map
- Tested on a single card: RTX 5090 FE (Blackwell GB202)
Decision guide
Section titled “Decision guide”The same three jobs as a list:
- An undervolt curve that survives a driver reload:
setwrites it with a read-back verify,persistinstalls the logon task, andholdre-applies it after a TDR (4101) or a driver install (UserPnp 20003) instead of polling. - Fan curves that run with no software in the loop:
holdwrites the fitted curves into the NCT6799D at logon and re-reads them on the 15-minute safety check, andvfctl fan restoreputs the saved BIOS register values back. - A session’s telemetry, and the search for the stability cliff:
watchlogs clock, voltage, utilisation, temperature and power to CSV and prints a per-voltage histogram;teststeps down 15 MHz on a TDR and retests.
References
Section titled “References”-
st4rdog, “MSI Afterburner curve editor shortcuts,” GitHub Gist. https://gist.github.com/st4rdog/d305609977037e64684a7932609446de ↩ ↩2
-
jpietek, “hidden_nvapi_vf.py,” PenguinBurner. https://github.com/jpietek/PenguinBurner/blob/d8901e64a9c7b479d6ae4ced63b7a2048b61e3ce/hidden_nvapi_vf.py ↩
-
Loong0x00, “Feature: Per-point V/F curve reading and editing for NVIDIA GPUs via undocumented NvAPI,” LACT issue #936. https://github.com/ilya-zlobintsev/LACT/issues/936 ↩
-
NVIDIA, “NVAPI,” GitHub repository. https://github.com/NVIDIA/nvapi ↩
-
arcnmx, “nvapi-rs,” Rust crate. https://github.com/arcnmx/nvapi-rs ↩
-
arcnmx, “nvapi-sys,” Rust crate. https://docs.rs/nvapi-sys - struct layouts for power/thermal reads ↩
-
NVIDIA, “NVAPI Reference Documentation,” Release 590. https://docs.nvidia.com/nvapi - documented clock/thermal APIs ↩
-
namazso, “PawnIO,” scriptable kernel driver for hardware access. https://pawnio.eu ↩
-
namazso, “LpcIO.p,” PawnIO.Modules. https://github.com/namazso/PawnIO.Modules/blob/24425a5299e84410751da882c121f322fb030b82/LpcIO.p ↩ ↩2
-
Linux kernel, “nct6775-core.c,” hwmon driver for Nuvoton NCT677x/679x Super I/O chips. https://github.com/torvalds/linux/blob/0fcb05b72344f40806cbe810de8872f1698bf053/drivers/hwmon/nct6775-core.c ↩
-
Nuvoton, “NCT6796D Datasheet,” Version 0.6, 2017. https://www.nuvoton.com/resource-files/NCT6796D_Datasheet_V0_6.pdf ↩ ↩2
-
XBAB Tech, “MousePlotter.” https://github.com/XBAB-Tech/MousePlotter ↩
-
Unwinder, “Does hardware polling software like RTSS, HWiNFO64 have a discernible impact on performance?,” Guru3D forums. https://forums.guru3d.com/threads/does-hardware-polling-software-like-rtss-hwinfo64-have-a-discernible-impact-on-performance.443665/ ↩
-
I. Zlobintsev, “feat: add Nvidia VF curve editor,” LACT pull request #957, merged 2026-04-18. https://github.com/ilya-zlobintsev/LACT/pull/957 ↩