From c86284739479c406634eab56ff1c885de5861fa6 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Mon, 7 Sep 2020 11:06:08 -0400 Subject: [PATCH] Set compression level of system::archiveFolder() .tar.zst file. --- src/patch.cpp | 6 ++++++ src/system.cpp | 9 +++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/patch.cpp b/src/patch.cpp index a2050f7d..d4a4490b 100644 --- a/src/patch.cpp +++ b/src/patch.cpp @@ -62,7 +62,10 @@ void PatchManager::save(std::string path) { INFO("Saving patch %s", path.c_str()); saveAutosave(); + uint64_t startTime = system::getNanoseconds(); system::archiveFolder(path, asset::autosavePath); + uint64_t endTime = system::getNanoseconds(); + INFO("Archived patch in %lf seconds", (endTime - startTime) / 1e9); } @@ -190,7 +193,10 @@ void PatchManager::load(std::string path) { } else { // Extract the .vcv file as a .tar.zst archive. + uint64_t startTime = system::getNanoseconds(); system::unarchiveToFolder(path, asset::autosavePath); + uint64_t endTime = system::getNanoseconds(); + INFO("Unarchived patch in %lf seconds", (endTime - startTime) / 1e9); } loadAutosave(); diff --git a/src/system.cpp b/src/system.cpp index c67563ef..5ffff82f 100644 --- a/src/system.cpp +++ b/src/system.cpp @@ -182,6 +182,11 @@ void archiveFolder(const std::string& archivePath, const std::string& folderPath DEFER({archive_write_free(a);}); archive_write_set_format_ustar(a); archive_write_add_filter_zstd(a); + // Set compression level roughly so that a 500MB/s SSD is bottlenecked + r = archive_write_set_filter_option(a, NULL, "compression-level", "1"); + if (r < ARCHIVE_OK) + throw Exception(string::f("archiveFolder() could not set filter option: %s", archive_error_string(a))); + #if defined ARCH_WIN r = archive_write_open_filename_w(a, string::U8toU16(archivePath).c_str()); #else @@ -245,7 +250,7 @@ void archiveFolder(const std::string& archivePath, const std::string& folderPath #endif FILE* f = std::fopen(entrySourcePath.c_str(), "rb"); DEFER({std::fclose(f);}); - char buf[1 << 14]; + char buf[1 << 16]; ssize_t len; while ((len = std::fread(buf, 1, sizeof(buf), f)) > 0) { archive_write_data(a, buf, len); @@ -266,7 +271,7 @@ void unarchiveToFolder(const std::string& archivePath, const std::string& folder archive_read_support_format_tar(a); // archive_read_support_format_all(a); #if defined ARCH_WIN - r = archive_read_open_filename_w(a, string::U8toU16(archivePath).c_str(), 1 << 14); + r = archive_read_open_filename_w(a, string::U8toU16(archivePath).c_str(), 1 << 16); #else r = archive_read_open_filename(a, archivePath.c_str(), 1 << 14); #endif