From 3ec513ecf21b2ec8b64c8548e9bb5b4173eb7a5f Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Tue, 4 Apr 2023 17:25:19 +0200 Subject: [PATCH] xzcat: Use BufferedFile for reading inputs This improves the decompression time of `clang-15.0.7.src.tar.xz` from 41 seconds down to about 5 seconds. The reason for this very significant improvement is that LZMA, the underlying compression of XZ, fills its range decompressor one byte at a time, causing a lot of overhead at the syscall barrier. --- Userland/Utilities/xzcat.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Userland/Utilities/xzcat.cpp b/Userland/Utilities/xzcat.cpp index 81ffe61a459..19837711e85 100644 --- a/Userland/Utilities/xzcat.cpp +++ b/Userland/Utilities/xzcat.cpp @@ -22,7 +22,8 @@ ErrorOr serenity_main(Main::Arguments arguments) args_parser.parse(arguments); auto file = TRY(Core::File::open_file_or_standard_stream(filename, Core::File::OpenMode::Read)); - auto stream = TRY(Compress::XzDecompressor::create(move(file))); + auto buffered_file = TRY(Core::BufferedFile::create(move(file))); + auto stream = TRY(Compress::XzDecompressor::create(move(buffered_file))); // Arbitrarily chosen buffer size. Array buffer;