From 37693c47a49252861a9512a42a5b17250d60a857 Mon Sep 17 00:00:00 2001 From: наб Date: Sat, 2 Nov 2024 17:50:12 +0100 Subject: LzmaFileFdPrivate: bump I/O buffer from 4k to 64k In #924761, the package reading times are really high. The main thing in strace is read(64, ..., 4096) with a backtrace of Thread 1 "python3" hit Breakpoint 1.7, __GI___libc_read (fd=64, buf=0x19f6820, nbytes=4096) at ../sysdeps/unix/sysv/linux/read.c:26 26 in ../sysdeps/unix/sysv/linux/read.c (gdb) bt #0 __GI___libc_read (fd=64, buf=0x19f6820, nbytes=4096) at ../sysdeps/unix/sysv/linux/read.c:26 #1 0x00007ffff7d22220 in __GI__IO_file_xsgetn (fp=0xecce20, data=, n=4096) at ./libio/libioP.h:947 #2 0x00007ffff7d17715 in __GI__IO_fread (buf=0x19f6820, size=1, count=4096, fp=0xecce20) at ./libio/iofread.c:38 #3 0x00007ffff6e58de1 in ?? () from /lib/x86_64-linux-gnu/libapt-pkg.so.6.0 #4 0x00007ffff6e533eb in FileFd::Read(void*, unsigned long long, unsigned long long*) () from /lib/x86_64-linux-gnu/libapt-pkg.so.6.0 #5 0x00007ffff6e4f517 in ExtractTar::Go(pkgDirStream&) () from /lib/x86_64-linux-gnu/libapt-pkg.so.6.0 #6 0x00007ffff5679619 in ?? () from /usr/lib/python3/dist-packages/apt_inst.cpython-311-x86_64-linux-gnu.so #7 0x00000000005230d0 in ?? () #8 0x000000000053ac2c in PyObject_Vectorcall () After modifying gdebi-gtk to crash after startup (averages over 3 runs): $ time PYTHONPATH=. python3 ./gdebi-gtk atom-amd64.deb TypeError: exceptions must derive from BaseException real 0m15.250s user 0m14.170s sys 0m00.881s $ time PYTHONPATH=. LD_LIBRARY_PATH=/home/nabijaczleweli/uwu/apt/build/apt-pkg/ python3 ./gdebi-gtk atom-amd64.deb TypeError: exceptions must derive from BaseException real 0m13.097s user 0m12.052s sys 0m00.823s so this is a 2.2s win on $ wget https://github.com/atom/atom/releases/download/v1.60.0/atom-amd64.deb $ l atom-amd64.deb -rw-r--r-- 1 nabijaczleweli users 132.3M 2022-03-08 atom-amd64.deb $ ar t atom-amd64.deb debian-binary control.tar.xz data.tar.xz Bumping the buffer to 1M averages to real 0m12.707s user 0m11.833s sys 0m00.732s (2.5s gain) so this is basically a wash and LZMA overpowers any further gains. --- apt-pkg/contrib/fileutl.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apt-pkg') diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index 08428e79b..262d1c8b3 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -1995,7 +1995,7 @@ class APT_HIDDEN LzmaFileFdPrivate: public FileFdPrivate { /*{{{*/ struct LZMAFILE { FILE* file; FileFd * const filefd; - uint8_t buffer[4096]; + uint8_t buffer[APT_BUFFER_SIZE]; lzma_stream stream; lzma_ret err; bool eof; -- cgit v1.2.3-70-g09d2