From c0eb95481f021089cd7eeaa4b866c9b18e0f8661 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Sun, 7 Mar 2021 13:48:51 +0100 Subject: VolumeVerifier: Align partition reads to groups This improves the speed of verifying Wii WIA/RVZ files. For me, the verification speed for LZMA2-compressed files has gone from 11-12 MiB/s to 13-14 MiB/s. One thing VolumeVerifier does to achieve parallelism is to compute hashes for one chunk of data while reading the next chunk of data. In master, when reading data from a Wii partition, each such chunk is 32 KiB. This is normally fine, but with WIA and RVZ it leads to rather lopsided read times (without the compute times being lopsided): The first 32 KiB of each 2 MiB takes a long time to read, and the remaining part of the 2 MiB can be read nearly instantly. (The WIA/RVZ code has to read the entire 2 MiB in order to compute hashes which appear at the beginning of the 2 MiB, and then caches the result afterwards.) This leads to us at times not doing much reading and at other times not doing much computation. To improve this, this change makes us use 2 MiB chunks instead of 32 KiB chunks when reading from Wii partitions. (block = 32 KiB, group = 2 MiB) --- Source/Core/DiscIO/VolumeWii.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'Source/Core/DiscIO/VolumeWii.cpp') diff --git a/Source/Core/DiscIO/VolumeWii.cpp b/Source/Core/DiscIO/VolumeWii.cpp index 63e20ec1e6..cf5503458a 100644 --- a/Source/Core/DiscIO/VolumeWii.cpp +++ b/Source/Core/DiscIO/VolumeWii.cpp @@ -412,12 +412,9 @@ bool VolumeWii::CheckH3TableIntegrity(const Partition& partition) const return h3_table_sha1 == contents[0].sha1; } -bool VolumeWii::CheckBlockIntegrity(u64 block_index, const std::vector& encrypted_data, +bool VolumeWii::CheckBlockIntegrity(u64 block_index, const u8* encrypted_data, const Partition& partition) const { - if (encrypted_data.size() != BLOCK_TOTAL_SIZE) - return false; - auto it = m_partitions.find(partition); if (it == m_partitions.end()) return false; @@ -431,10 +428,10 @@ bool VolumeWii::CheckBlockIntegrity(u64 block_index, const std::vector& encr return false; HashBlock hashes; - DecryptBlockHashes(encrypted_data.data(), &hashes, aes_context); + DecryptBlockHashes(encrypted_data, &hashes, aes_context); u8 cluster_data[BLOCK_DATA_SIZE]; - DecryptBlockData(encrypted_data.data(), cluster_data, aes_context); + DecryptBlockData(encrypted_data, cluster_data, aes_context); for (u32 hash_index = 0; hash_index < 31; ++hash_index) { @@ -474,7 +471,7 @@ bool VolumeWii::CheckBlockIntegrity(u64 block_index, const Partition& partition) std::vector cluster(BLOCK_TOTAL_SIZE); if (!m_reader->Read(cluster_offset, cluster.size(), cluster.data())) return false; - return CheckBlockIntegrity(block_index, cluster, partition); + return CheckBlockIntegrity(block_index, cluster.data(), partition); } bool VolumeWii::HashGroup(const std::array in[BLOCKS_PER_GROUP], -- cgit v1.2.3