# NoLag — setup and use

This revision starts from the complete uploaded Python application. The dashboard, Windows settings catalogue, game watcher, custom games, connection monitor, Lag Doctor, candidate remote detection, activity log and optional licensing configuration remain. The interface uses near-black surfaces, deep-purple cards, lavender accents, a sidebar and a dedicated Connection lab. Buttons and switches support keyboard activation. The new GPU & profiles page adapts to detected hardware rather than targeting one person's PC.

## Install and launch

Use **Windows 10/11, 64-bit Python 3.9 or later** with Tkinter. Python 3.11 or later is recommended. The standard python.org Windows installer includes Tkinter; select it if choosing components. Save the delivered files together in a folder.

Open a terminal in that folder:

```powershell
py -m pip install -r requirements.txt
py NoLag.py
```

If the Python launcher `py` is unavailable, substitute `python` for `py`. Use the same Python installation for installation and launch. A virtual environment is optional. No additional DNS, driver or packet-capture package is required.

Launch with standard access for diagnostics. Windows preferences, the optional peer-sharing policy and most advanced system actions require **Run as admin** in the sidebar, Windows UAC approval, and then repeating the action. Use the same Windows account when elevating so user preferences and backups stay associated with the intended account. If UAC is cancelled, the original application stays open. Relaunching normally restores any current game boost first; wait for an active task to finish before relaunching.

If Python says Tkinter is missing, modify/reinstall Python with the Tcl/Tk component. If it says psutil is missing, repeat the dependency command using the interpreter that launches the app.

## Run a measured connection test

1. Open **Connection lab**. Enter the game's known IPv4 address if available, or a hostname. The default `1.1.1.1` is an internet reference, not a game server. IPv6 targets and URLs are not supported by this diagnostic.
2. First leave the optional peer-sharing checkbox **off**. Pause downloads/streams manually and keep the game, connection, VPN, region and workload stable.
3. Select **Run before / after**. The app resolves the target once and sends 20 ICMP echo probes per endpoint in each window. Router and internet reference probes run alongside it where applicable. Live dashboard probing and watcher ticks pause during the task.
4. Inspect both windows: median RTT, adjacent-sample jitter, no-reply percentage and reply count. The export includes every raw sample/error, mean/min/max RTT, route information, UTC timestamps and aggregate system network traffic.
5. Use **Export report** to save JSON. Repeat several times and compare with the game's own latency/packet-loss display. A lower observed value in one short test does not prove a lasting benefit.

Measurements use the Windows ICMP API rather than parsing localized `ping` output. A hostname failure stops the run; blocked probes are retained as failures, not discarded to manufacture a better average. Fewer than 16 successful target replies in either 20-probe window makes the comparison inconclusive. Missing route information or a route/adapter change invalidates the target comparison. A candidate remote may belong to a game launcher, voice service or CDN; inspect and confirm it before treating it as the gameplay server.

ICMP echo RTT is **not** game-protocol RTT. No reply can mean ICMP filtering, deprioritization or rate limiting; it is **not automatically game packet loss**. Jitter here is the mean absolute RTT difference between consecutive successful probes; missing probes are not bridged. Aggregate traffic includes all interfaces and the diagnostic's own traffic. The target IP is held fixed so DNS changes cannot masquerade as a latency improvement.

## Optional reversible optimization

The optional checkbox sets the Windows `DODownloadMode` policy to **0 (HTTP only; no peer sharing)** between the two windows. Windows update HTTP downloads continue. This can reduce competition only when update peer traffic is actually relevant; the app does not claim to prove that peer traffic caused a delay. It does not stop updates, close applications, change a matchmaking region, modify DNS or tune adapters.

The policy value's original existence, type and data are saved **before** writing. Writes and restores are read back. If writing fails, the app attempts rollback; a failed rollback retains the backup for recovery. An interrupted run leaves any successful change recorded; use **Restore peer sharing** after the task has stopped. Restore is available after restarting the app as well.

The optional action is skipped if the first target window has insufficient replies or the route cannot be verified as stable. Registry verification proves the stored value, not immediate enforcement by Windows or an organization policy. Group Policy/MDM, Windows edition and policy refresh can affect effective behavior; use the Windows Delivery Optimization settings to check it. On a managed PC, follow your administrator's configuration.

Microsoft documents [HTTP-only/no-peering mode](https://learn.microsoft.com/en-us/windows/deployment/do/delivery-optimization-configure) and [ICMP ping diagnostics](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ping).

## DNS and regional reference tools

**Benchmark DNS queries** sends UDP DNS A queries to the listed providers for three public domains, repeated once. Responses must match the transaction/question, indicate success, and contain a complete IPv4 answer; truncated or error responses are rejected. A median is shown only with at least five valid responses out of six. Provider caches and filtering affect results; this is a small lookup benchmark, not a comprehensive resolver recommendation. The domains queried and your public source address are visible to those resolvers. DNS is never switched automatically.

**Test AWS references** measures three TCP port-443 connection attempts per region after resolving its AWS EC2 API hostname. The median and successful-attempt count are shown. These are AWS control-plane endpoints, **not game matchmaking servers**; their routes may differ. The app no longer maps these timings into purported best Fortnite regions. Confirm matchmaking choices in the game.

If you choose to change DNS yourself, record the adapter's existing static IPv4/IPv6 servers or automatic/DHCP configuration before using **Windows network settings**. Restore that configuration manually if needed. A faster lookup does not imply lower RTT to an already connected game server.

## Universal GPU detection and monitoring

Open **GPU & profiles**. Hardware is detected in the background on launch; **Refresh hardware** repeats it. The app reports CPU, RAM, Windows version, reported GPU names/drivers, and attached displays with current mode/refresh rate. All reported GPUs are retained, including hybrid-laptop integrated/discrete combinations. Selecting **GPU context** chooses the profile's intended hardware context; it does not prove which GPU the game currently uses.

Inventory uses read-only Windows CIM queries. If those are blocked, active display-adapter names and basic CPU/Windows information are used as an explicit fallback. The fallback cannot identify headless cards, distinguish identical physical cards reliably, or supply driver versions. Unknown information is labelled unavailable.

**Refresh GPU readings** provides read-only samples. Readings also refresh every eight seconds while the page is open and no main task is running:

- NVIDIA cards: the installed `nvidia-smi` utility can expose each GPU's UUID, utilization, memory usage/capacity, temperature and power. Unsupported sensors show unavailable, not zero. The utility is not installed/downloaded automatically.
- All vendors: Windows GPU engine and adapter-memory counters are used when available. The busiest engine reading covers all processes/adapters and is **not whole-GPU utilization**. Dedicated/shared memory totals are system-wide counter usage, not a capacity inferred from old WMI AdapterRAM values.
- AMD/Intel/unknown cards: temperature/power/capacity are unavailable unless exposed through an installed supported provider. This build does not bundle ADLX, Intel sensor SDKs or a custom kernel driver.

The compatibility guidance changes for NVIDIA, AMD, Intel or unknown hardware and the selected goal. NVIDIA Reflex, AMD Anti-Lag/Anti-Lag 2 and Intel XeSS guidance is conditional: vendor detection does not verify support in a particular GPU/game/version. Official vendor documentation links are provided. Driver/in-game features are not silently switched on. Some upscalers can work across vendors; check the specific game and feature version.

## Per-game profiles and Windows GPU preference

Create a profile for any desktop game's executable. Record its name/path, goal, GPU context, planned FPS cap, resolution, quality, latency/frame-generation options, repeatable benchmark scene and other workload notes. **Save profile records a plan only**; set those game/driver options manually. The original automatic game watcher remains a separate opt-in feature.

The new automatic graphics action is **Apply Windows GPU preference**:

1. Browse to the actual installed game `.exe`, save the profile, and choose Let Windows decide, Power saving GPU or High performance GPU.
2. Use administrator mode, then review the executable, original value and proposed value in the confirmation.
3. NoLag backs up the exact existing `HKCU\Software\Microsoft\DirectX\UserGpuPreferences` value/type or absence before writing the `GpuPreference` token. Other tokens such as AutoHDR are preserved. The write is verified directly through the registry, without passing profile strings to a shell.
4. Restart the game and verify its GPU in Task Manager or Windows Graphics settings. This preference is not a guaranteed assignment of a particular physical GPU, and behavior can vary by Windows/driver/application.
5. **Restore GPU preference** restores the original value. **Undo everything** also finds these exact backups after an app restart. Apply a different preference only after restoring the previous recorded change. Default-based GPU undo is refused when the exact backup is missing.

Use the same Windows account when elevating. Select the real rendering executable rather than a launcher. Games distributed through mechanisms without an accessible desktop executable can still have manual profile notes and CSV imports; automatic per-executable preference requires a valid file path. No voltage, clock, overclock, undervolt, driver injection or display-refresh mutation is added.

## Frame-time benchmarks and comparisons

PresentMon is optional. Existing CSVs can be imported with no external recorder installed. To capture inside NoLag:

1. Get the **standalone PresentMon console executable** from the app's Official download link or [official releases](https://github.com/GameTechDev/PresentMon/releases). Select it with **Choose PresentMon**. The GUI installer/service application is not the console executable.
2. Save a game profile with the actual executable name and a repeatable scene, such as a specific training route or built-in benchmark. Set/record the actual game/driver settings and tick the confirmation. Editing profile fields clears that confirmation.
3. Start the game. Set a run label (for example Baseline), duration (10–180 seconds) and start delay (0–30 seconds). Leave PID blank to find a unique matching running process. If multiple matching processes exist, enter the actual gameplay PID; the app will not guess. A stored full executable path is also checked.
4. Select **Capture run** and review the external tool action. Play the same scene after the delay. NoLag invokes the console with a process filter, local CSV output, a unique session name, timed exit and `--v1_metrics`. It does not replace/stop another recorder's session. Some Windows configurations require running NoLag as admin; failure is reported without automatic elevation.
5. Change one intended setting, update the profile notes, and repeat with a new run label. Ctrl-click exactly two runs and select **Compare two runs**. A is the older run and B is the newer run.

The [official console documentation](https://github.com/GameTechDev/PresentMon/blob/main/README-ConsoleApplication.md) describes supported flags and CSV metrics. NoLag imports `MsBetweenPresents` with `Application`, `ProcessID` and `SwapChainAddress`. It will not substitute GPU duration, display latency or an unrelated FPS column. CSVs using another layout need a compatible PresentMon export.

The importer filters the profile's executable (and the captured PID for a local capture), then chooses the process/swapchain with the most valid intervals. Other streams are not mixed together; the selected stream and number seen are reported. This heuristic can still choose a menu/secondary swapchain: inspect the scene and stream information. Nonfinite, zero or missing intervals are rejected. At least 120 valid intervals are needed to import; comparison needs at least 300 intervals and ten seconds in **each** run.

Metrics are defined explicitly:

- Average FPS = 1000 divided by the mean positive present interval in milliseconds.
- 1% low FPS = 1000 divided by the mean of the slowest ceiling(1% of intervals). Other benchmarking tools may use a different definition.
- p99 frame interval uses linear percentile interpolation.
- The stutter heuristic counts intervals above max(33.33 ms, twice the run median). It is a descriptive rule, not a diagnosis. A separate count above 33.33 ms uses the same fixed threshold across runs.
- The graph plots the maximum interval in each bin so downsampling preserves spikes. Export contains every stored interval.

For live captures, system CPU usage, aggregate network traffic, RAM and battery/AC state are recorded around the tool run, including its start delay. Available NVIDIA sensor snapshots are collected at the edges; they are not continuous thermal measurements. Comparisons warn about substantial CPU-load, network-traffic, ending-temperature or AC-state differences, differing hardware/driver/display inventory, differing durations and recorded setting changes. A changed/missing scene or different game/metric prevents comparison. Imports have explicitly unverified hardware/settings association. The user's settings confirmation is a record, not independent inspection of the game's configuration.

These are **application present-cadence metrics**, not guaranteed displayed-frame counts, input-to-photon latency or server ping. Frame generation, multiple swapchains, menus/background states and workload differences can affect interpretation. Repeat runs; observed changes do not prove causation.

**Export runs** saves profiles, hardware context, workload data and full stored intervals as JSON. NoLag retains the most recent 20 runs in its local history. Raw captured CSVs remain in `%APPDATA%\NoLag\benchmarks`; export older runs before the local history rolls over. Imports are capped at 128 MiB, 1,000,000 input rows and 250,000 matching valid intervals to bound memory use. Cancelled/failed captures may leave raw CSVs but are not added as completed benchmarks. Process/executable paths and hardware identifiers appear in exports; inspect them before sharing.

## Windows presets and advanced actions

**Game Ready / Game preferences** now reviews only six game/visual preferences: Game Mode, background Game DVR recording, Game Bar capture, the Game Bar startup panel, desktop transparency and taskbar animations. Recording/capture is disabled by this preset until restored. Each preference receives an exact registry backup. No network, service, power, storage or cleanup changes are in the preset. Auto-boost must be enabled separately in Play.

The broad Nagle, QoS, TTL, TIME_WAIT, adapter offload/power, tunneling and DNS actions are disabled for new application. Their old IDs remain so legacy state can be recognized. The peer-sharing policy is an individually reviewed action, not part of a broad network preset.

Other advanced preferences/actions are retained for practical compatibility, with individual review. Registry-only actions get exact value backups. Legacy power/service/mixed actions retain the original application's **default-based undo**, which can differ from the previous configuration. Multi-command advanced actions may partially apply if a later command fails; the recorded ID remains available for reviewed undo. Some retained advanced scripts have limited verification; they are not covered by the registry transaction guarantee. Reboots/sign-out may be necessary where described.

Cleanup and network reset actions are one-time manual operations and are excluded from presets. Cleanup deletions cannot be undone in NoLag. Winsock/TCP reset can affect VPNs or static addressing; the confirmation describes them as non-undoable. Do not treat the legacy catalogue as a list of proven FPS improvements.

Auto-boost restores process priorities and the saved power plan on a normal game exit or normal app close. Forced termination, a crash or power loss cannot guarantee that restoration; use Task Manager and Windows power settings if recovery is needed. Game anti-cheat may deny priority changes. Traffic-based candidate detection requires Windows administrator access and may miss traffic or misidentify a service. Online IP-location lookup is off by default; if enabled, the candidate remote IP is sent to the listed IP-information services.

## Backups and recovery

Persistent files are stored under `%APPDATA%\NoLag`:

- `registry-backups-v2.json`: exact registry snapshots and completed-restore markers, including interrupted changes.
- `state.json`: recorded legacy/applied IDs.
- `settings.json`: app preferences.
- `last-network-report.json`: most recently completed diagnostic report.
- `game-profiles-v3.json`: saved profiles and the optional PresentMon tool path.
- `frame-benchmarks-v3.json`: the most recent 20 frame-time runs and their context.
- `benchmarks\*.csv`: raw local PresentMon captures.
- Existing license and AWS range cache files remain compatible.

Keep the backup file until all desired changes are restored. **Undo everything NoLag applied** restores exact v2 backups and asks explicitly before default-based legacy undo. Old NoLag did not save original DNS values, so the app cannot reconstruct them. Inspect any old DNS configuration and restore your known prior settings manually. If a backup/state file is corrupt or unreadable, startup stops with an error rather than silently losing recovery data. Preserve the file before attempting repair.

Registry restoration restores the values/types (or absence), but may leave empty registry keys created by the app. The app does not create a Windows restore point for the reviewed registry preset; its protection is the write-ahead registry backup. Manually created system restore points can provide an additional recovery layer for advanced actions.

## Validation and limits

Validation for this GPU revision:

- Source and delivered test scripts compile successfully.
- 38 logic tests passed; the one native ICMP test was explicitly skipped under the current restricted permissions. Coverage includes the existing network/rollback logic plus mixed/unknown GPU detection, fallback inventory, unavailable sensors, profile persistence, direct-registry GPU actions, PresentMon command isolation/cancellation, CSV process/swapchain filtering, metric definitions and workload comparison warnings.
- Read-only display enumeration succeeded. Full CIM GPU/CPU/Windows inventory is blocked in this execution environment; its labelled fallback/error path was exercised. Multiple vendor scenarios were simulated in tests.
- The earlier six-page build passed a live Tkinter smoke check. The new seven-page UI has not been launched in this revision's restricted environment. An opt-in `test_ui.py` is included to check page construction, mixed-GPU guidance, profile saving, unavailable readings and graph rendering on a normal Windows desktop. Full visual/DPI/accessibility validation still needs local checking.

Registry tests simulate mutations and recovery. Actual Windows GPU preference behavior, real GPU sensors across vendors and an installed PresentMon capture have not been tested on this host. No FPS, input-latency or game-ping improvement is claimed.

To run the delivered tests (no system configuration changes):

```powershell
py -m py_compile NoLag.py
py test_nolag.py
py test_gpu.py
# Optional local GUI smoke check (simulated data; no network/registry changes):
py test_ui.py
```

One test uses read-only ICMP loopback; restrictive sandboxes/security software may block it. Set `NOLAG_SKIP_NATIVE_TESTS=1` only when that native test cannot run; the normal default runs it. The test suite otherwise mocks mutations, sensor providers, external recorder execution and external network probes. The optional original license system is retained with `LICENSE_PUBLIC = None`, so all features in this build are unlocked; purchasing/key-generation infrastructure is not included or required to run it.
