I have seen in the past a couple of cases where increasing the size of the discard granularity had a positive impact on trimming times, but in those instances we recommended a much smaller, conservative, increments.
It's not trimming times alone - it's that the defrag service in Windows acts like it has a memory leak if these slabs are too small, and the guest effectively crawls to a halt if you have a sizeable disk. I find this not to be an issue on WS2019 (v1809) but on WS2022 and above it is immediately obvious. Assume clients of similar vintage are the same. Windows automates a weekly optimize task once a week out of the box
In testing, an 80GB disk caused it to take about 5-6 minutes and eat a few GB of RAM and a bunch of IO - i assume moving individual 4k blocks around.. I stress I only found this when investigating.. it's not something you'll notice unless you're watching graphs. Another with a 1TB disk ate 32GB of allocated guest RAM before hitting its page file - that machine went into a loop - unable to complete the scheduled volume optimize task, crashing, being manually rebooted, and back around within a few hours.
Changing the slab size solved this problem. Experience suggests to me that reducing the slab count on a 1TB disk from over 268 million (at the default discard_granularity=4k) to 32,000 (by increasing discard_granularity=32MB) helps that avoid windows' defrag service from going off the rails
I followed up to verify what microsoft is doing with Hyper-V - it is obviously a completely different underlying technology but with an "out of the box" config Hyper-V host (Server 2019), the value passed through to a guest VM is a 32MB slab size. Conclusive evidence? no, but in lieu of much else...
According to the source, this should be fixed with patches dating to August 2014. So it might be a similar, but ultimately different issue (unless one uses a non-updated windows 2012 version).
I agree, it could be something unrelated - other threads on this topic have considered it relevant. Some suggest this was an out-of-band patch and didn't make it to later versions of Windows. This problem is definitely a long-standing one and not just for Proxmox.
The "solution" post from "alldiscoveries" says 2MB slab sizes and my findings say 32MB. Microsoft appear, maybe, at some point, possibly to have said no less than 8MB, therefore 32MB seems the more sensible option. My intent here was just to point that out