Open Kobi-Blade opened 5 days ago
Adding to my original post, SSDs have a limited number of write cycles, and pre-allocating space means writing unnecessary data. By using the --file-allocation=none parameter, we can avoid these unnecessary writes and extend the lifespan of the SSD.
To detect if a system is using an SSD or HDD in C++, you can use the Windows API to query the drive type. Here's a sample code snippet that demonstrates how to do this:
#include <windows.h>
#include <string>
#include <cstdlib>
bool IsSSD(const std::wstring& drive) {
HANDLE hDevice = CreateFileW((L"\\\\.\\" + drive).c_str(), 0, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
if (hDevice == INVALID_HANDLE_VALUE) {
return false;
}
STORAGE_PROPERTY_QUERY storagePropertyQuery;
ZeroMemory(&storagePropertyQuery, sizeof(STORAGE_PROPERTY_QUERY));
storagePropertyQuery.PropertyId = StorageDeviceSeekPenaltyProperty;
storagePropertyQuery.QueryType = PropertyStandardQuery;
DEVICE_SEEK_PENALTY_DESCRIPTOR seekPenaltyDescriptor;
ZeroMemory(&seekPenaltyDescriptor, sizeof(DEVICE_SEEK_PENALTY_DESCRIPTOR));
DWORD bytesReturned = 0;
if (!DeviceIoControl(hDevice, IOCTL_STORAGE_QUERY_PROPERTY, &storagePropertyQuery, sizeof(STORAGE_PROPERTY_QUERY), &seekPenaltyDescriptor, sizeof(DEVICE_SEEK_PENALTY_DESCRIPTOR), &bytesReturned, NULL)) {
CloseHandle(hDevice);
return false;
}
CloseHandle(hDevice);
return !seekPenaltyDescriptor.IncursSeekPenalty;
}
The snippet above checks if the specified drive (in this case, C:) is an SSD by querying the StorageDeviceSeekPenaltyProperty. SSDs do not incur a seek penalty, so if the IncursSeekPenalty property is false, the drive is an SSD.
I know it's probably not your intention, but you don't need to explain SSD write cycles to us. Despite the FFXI themed raid getting people nostalgic, it's not the mid 2000s and the first post explaining that there's an argument we can supply to the binary was plenty.
But additionally, if patching FFXIV has you concerned about your disk's overall lifetime, there may be larger issues at play.
Adding a c++ binary to pinvoke to check the storage medium type would be excessive. Even something managed inside of dotnet like that detailed on < https://stackoverflow.com/a/76883160> would be. We can just add the argument.
Update disclaimer
What did you do?
I have noticed that the current implementation of aria2 in XIV Launcher does not utilize the --file-allocation=none parameter when running on SSD systems. This parameter is crucial for optimizing performance on SSDs, as it prevents unnecessary wear and tear caused by file allocation operations that are only beneficial on HDDs.
Steps to Reproduce:
Launch XIV Launcher on a system with an SSD.
Observe the file allocation behavior during game updates.
Expected Behavior: The --file-allocation=none parameter should be used to prevent unnecessary file allocation on SSDs.
Actual Behavior: File allocation is performed, which is unnecessary and can lead to increased wear on the SSD.
Platform
Windows
Wine/Proton runner version
No response
Relevant log output