Adjust for Best Performance: Windows Themes and Power

These are 2 low-hanging fruit settings that make SQL Server run better. Adjust theme for Best Performance and power option for High Performance.

0.Run.bat – Run as administrator!

@ECHO Off
@ECHO ********** Cmds Started %DATE% %TIME% ********** >>Output.txt

Set Server=ProdSvrSQL1
Set UptoScript=99
cls

@ECHO ON
@ECHO "%Server%" STARTED!!! >>Output.txt

@ECHO OFF 

rem IF %userdnsdomain%\%username% == FLEITASARTS.COM\_sql_service GOTO PART2
:PART1
@ECHO "2.BestPerformanceRestartThemes.cmd" STARTED!!! >>Output.txt
call 2.BestPerformanceRestartThemes.cmd >> Output.txt

@ECHO "2.PowerOptions.cmd" STARTED!!! >>Output.txt
if %UptoScript% LEQ 0 GOTO Verify
call 2.PowerOptions.cmd >> Output.txt
IF ERRORLEVEL 1 GOTO END

:Verify
@ECHO ON
@ECHO "%Server%" COMPLETED!!! >>Output.txt

@ECHO OFF
rem sqlcmd  /S "%Server%" /d "%Database%" /i "Scripts/Verify.Sql" /b >>Output.txt
IF ERRORLEVEL 1 GOTO END

echo. >>Output.txt
@ECHO ************* %DATE% %TIME% ************* >>Output.txt
@ECHO OFF

GOTO Exit

:END
echo Date: %Date% %Time%  PublishErrorlevel:%errorlevel% >>Output.txt

:Exit
call Output.txt

PAUSE

1.BestPerformance.reg

; ###
; Visual Effects
; ###

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects]
"VisualFXSetting"=dword:00000002

; Do not Animate windows when minimizing and maximizing
[HKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics]
"MinAnimate"="0"

; Disable Animations in Taskbar and Start Menu
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced]
"TaskbarAnimations"=0
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced]
"TaskbarAnimations"=-

; Disable desktop composition
[HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM]
"CompositionPolicy"=0

; Enable transparent glass
[HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM]
"ColorizationOpaqueBlend"=0

; Disable Taskbar Thumbnail Previews
[HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM]
"AlwaysHibernateThumbnails"=dword:00000000

; Disable Explorer Thumbnails (All Users)
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer]
"DisableThumbnails"=dword:00000001

; Disable translucent selection rectangle
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced]
"ListviewAlphaSelect"=0

; Dont show window contents while dragging
[HKEY_CURRENT_USER\Control Panel\Desktop]
"DragFullWindows"=0

; Dont smooth Edges of Screen Fonts
[HKEY_CURRENT_USER\Control Panel\Desktop]
"FontSmoothing"="0"

; Use drop shadows for icon labels on the desktop
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced]
"ListviewShadow"=0

; Disable visual styles on windows and buttons
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ThemeManager]
"ThemeActive"="0"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\ThemeManager]
"ThemeActive"=-

; Disable following:
; * Animate controls and elements inside windows
; * Smooth-scroll list boxes
; * Slide open combo boxes
; * Fade or slide menus into view
; * Show shadows under mouse pointer
; * Fade or slide ToolTips into view
; * Fade out menu items after clicking
; * Show shadows under windows
; * Use Visual styles on windows and buttons
[HKEY_CURRENT_USER\Control Panel\Desktop]
"UserPreferencesMask"=hex:90,12,01,80,10,00,00,00

; https://social.technet.microsoft.com/Forums/office/en-US/73d72328-38ed-4abe-a65d-83aaad0f9047/adjust-for-best-performance?forum=winserverpowershell

2.BestPerformanceRestartThemes.cmd

reg export "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects" "C:\fleitasarts\1.BestPerf.HKCUVisualEffects.BAK.reg" /y /reg:64
reg export "HKCU\Control Panel\Desktop\WindowMetrics" "C:\fleitasarts\1.BestPerf.HKCUWindowMetrics.BAK.reg" /y /reg:64
reg export "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" "C:\fleitasarts\1.BestPerf.HKCUAdvanced.BAK.reg" /y /reg:64
reg export "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" "C:\fleitasarts\1.BestPerf.HKLMAdvanced.BAK.reg" /y /reg:64
reg export "HKCU\Software\Microsoft\Windows\DWM" "C:\fleitasarts\1.BestPerf.HKCUDWM.BAK.reg" /y /reg:64
reg export "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" "C:\fleitasarts\1.BestPerf.HKCUExplorer.BAK.reg" /y /reg:64
reg export "HKCU\Control Panel\Desktop" "C:\fleitasarts\1.BestPerf.HKCUDesktop.BAK.reg" /y /reg:64
reg export "HKCU\Software\Microsoft\Windows\CurrentVersion\ThemeManager" "C:\fleitasarts\1.BestPerf.HKCUThemeManager.BAK.reg" /y /reg:64
reg export "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\ThemeManager" "C:\fleitasarts\1.BestPerf.HKLMThemeManager.BAK.reg" /y /reg:64

echo "Importing 1.BestPerformance.reg"
regedit /s 1.BestPerformance.reg
echo "Imported 1.BestPerformance.reg"

@Echo off
echo "Restart Themes/Temas Service ..."

net stop themes
net start themes

The script above helps tremendously when having to RDP over super-high latency networks (satellite) that have 2000+ ms (milliseconds) latency on a good day.

This is the setting I’m referring to, but via cmd line its much faster to do as keyboard input is faster than waiting for the mouse plus everything else to arrive/render across the network.

AdjustForBestPerformance

Now note, yes, if I recall correctly, this is specific to the user profile so I recommend doing this for the SQL Service profile and/or your own profile too if needed. Simply login once as that account and run the 1st file with the 3 files (contents) in the same folder.

run

Okay now for the more popular setting – Power Option High performance. In case you haven’t heard of it, the impact of leaving this to the default Balanced plan, is that it will throttle your CPU power consumption frequency down when the OS thinks its okay and that’s not okay for SQL Server. If you want to witness it for yourself just open Resource Monitor and under the CPU tab, keep an eye on % Maximum Frequency. While in Balanced plan you will see it drop under 100% quite often.

powercfg -s 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c
powercfg -l

This is the equivalent of selecting the plan like this.HighPerformance

The Output.txt will look like this.

Output

References:

  1. Microsoft Technet Social Forum: Ajust for best performance
  2. powercfg-command-line-options

Okay so that was a lot of syntax, screenshots and verbiage. I hope I didn’t loose anyone. Did it help?

Enjoy,
Hiram

 

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.