Server 2022 defrag/trim pegging CPU and RAM

alyarb

Well-Known Member
Feb 11, 2020
141
29
48
38
Different forms of this issue have been brought up a couple times in the past:
https://forum.proxmox.com/threads/windows-optimize-drives-ram-usage-best-practices.144703/
https://forum.proxmox.com/threads/memory-spikes-win-2022-trying-to-defragment-a-1tb-disk.136542/
https://forum.proxmox.com/threads/windows-vm-requires-lots-of-ram-to-trim-larger-hard-disks.96288/

The built-in Windows defrag utility and any scheduled disk optimization performed by the defragsvc service will peg 1 core, all the available free RAM, and the disk being "optimized."

When using the Optimize-Drive PowerShell cmdlet with only -Analyze, or only -ReTrim switches, it still takes a tremendous amount of time and resources to complete the operation than normal. When running it without custom switches it will also perform the /SlabConsolidate function. The VM is practically unresponsive during these operations.

I cannot reproduce this on any 2012, 2016, or 2019 VM. Only Server 2022.

The only proposed solution has been to set a custom discard_granularity on the VM conf.

I'm using virtio-scsi-single and have so far tried these vioscsi driver versions, I know there are more but this was a fairly wide spread:
100.82.104.18500
100.93.104.24000
100.100.104.26600

Ceph Quincy on Intel P4510 SSDs.


If hard-coding the discard granularity the only solution, of course I'm willing to do it, but I find it hard to believe that it has not yet been addressed properly either within the guest OS or at the qemu level, so I wanted to be sure before proceeding with modifying tons of confs and power cycling VMs.

Thank you!
 
Last edited: