From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 22FE3901BB; Wed, 5 Oct 2022 14:31:29 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id DE8321D58; Wed, 5 Oct 2022 14:30:58 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS; Wed, 5 Oct 2022 14:30:58 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id CE058433CB; Wed, 5 Oct 2022 14:30:51 +0200 (CEST) Message-ID: Date: Wed, 5 Oct 2022 14:30:50 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:106.0) Gecko/20100101 Thunderbird/106.0 From: Thomas Lamprecht To: Proxmox VE development discussion , Daniel Tschlatscher , pbs-devel@lists.proxmox.com, pmg-devel@lists.proxmox.com References: <20220907085633.89113-1-d.tschlatscher@proxmox.com> <20220907085633.89113-5-d.tschlatscher@proxmox.com> Content-Language: en-GB In-Reply-To: <20220907085633.89113-5-d.tschlatscher@proxmox.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-SPAM-LEVEL: Spam detection results: 0 AWL 1.196 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment NICE_REPLY_A -2.449 Looks like a legit reply (A) SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [tasks.pm] Subject: Re: [pbs-devel] [pve-devel] [PATCH manager v2 4/7] revised task log API call for PVE X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Oct 2022 12:31:29 -0000 Am 07/09/2022 um 10:56 schrieb Daniel Tschlatscher: > The API call for fetching a tasklog with limit=0 now returns the whole > log as a file stream rather than reading all lines in memory and then > transfering them in JSON format. The behaviour when the url parameter > limit is undefined or not 0 is the same as before, in accordance > with the API specification. > > Signed-off-by: Daniel Tschlatscher > --- > PVE/API2/Tasks.pm | 13 ++++++++++--- > 1 file changed, 10 insertions(+), 3 deletions(-) > > diff --git a/PVE/API2/Tasks.pm b/PVE/API2/Tasks.pm > index 9cd1e56b..88762f2f 100644 > --- a/PVE/API2/Tasks.pm > +++ b/PVE/API2/Tasks.pm > @@ -5,6 +5,7 @@ use warnings; > use POSIX; > use IO::File; > use File::ReadBackwards; > +use File::stat; > use PVE::Tools; > use PVE::SafeSyslog; > use PVE::RESTHandler; > @@ -387,11 +388,17 @@ __PACKAGE__->register_method({ > $rpcenv->check($user, "/nodes/$node", [ 'Sys.Audit' ]); > } > > - my ($count, $lines) = PVE::Tools::dump_logfile($filename, $start, $limit); > + if ($limit == 0) { > + # TCP Max Transfer Unit size is 1500, compression for lower numbers has no effect What do you mean here? The MTU of the Ethernet data layer? As that would make more sense, there the most common (but not guaranteed) MTU is indeed 1500. TCP can send more data per packet just fine if the MTU of the underlying (ethernet) network is bigger, like the often used MTU of 9000 in LANs. Note also that the actual file size that can be transmitted in one packet would need to factor in IP, TCP and HTTP overhead though. For IPv4 you'd use 16 byte for the IP and 24 bytes for the TCP part of the packet, so it'd be 1460 bytes, the HTTP header isn't as deterministic and for IPv6 it's more overhead eating away the possible payload size. That alls said, we could still use the 1500 as cut-off, nothing inherently against that per se, but the comment should not refer to the confusing TCP MTU and mention that the boundary depends. For finding a cutoff we could look at file distribution size of task log in existing (non-test) instances, e.g. with: find /var/log/pve/tasks/ -mindepth 2 -type f -print0 | xargs -0 ls -l | awk '{size[int(log($5)/log(2))]++}END{for (i in size) printf("%10d %3d\n", 2^i, size[i])}' | sort -n For three relatively active and long lived host this gives: Size A B C 1 8 567 669 121 16 3 28 32 40 106 6 64 60 23 128 63 28 256 22 25 8 512 8 12 4 1024 8 32 40 2048 2 12 17 4096 5 1 8192 14 1 695 16384 18 1 32768 24 I then compressed all files with gzip and reran: 32 1 64 596 128 154 256 14 512 13 1024 4 2048 14 4096 18 8192 24 32 1 64 784 128 74 256 38 512 41 1024 2 4096 1 8192 1 So, I'd just use 1024 as cut-off, that isn't bound to such dynamic limits like TCP actual payload per single package size, but will still fit in most and even captures most of the previously selected files in practice anyway. Also gzip is normally able to compress text quite well so doing that with log (i.e., not random data) text files bigger than 1KiB will almost never over the uncompressed limit. If you rather like a higher size you can also use 2 or 4 KiB, both fine too IMO. > + my $use_compression = stat($filename)->size > 1500; should be able to use: -s $filename > X > + return PVE::Tools::stream_file($filename, $param->{upid}, $use_compression); IMO the helper isn't to useful, I'd just do this inline. > + } else { no else required, other branch returns. > + my ($count, $lines) = PVE::Tools::dump_logfile($filename, $start, $limit); > > - $rpcenv->set_result_attrib('total', $count); > + $rpcenv->set_result_attrib('total', $count); > > - return $lines; > + return $lines; > + } > }}); > >