From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 81E8A138334 for ; Thu, 10 Jan 2019 15:30:39 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 4C7D9E09C0; Thu, 10 Jan 2019 15:30:38 +0000 (UTC) Received: from khnum.cheops.bitzolder.nl (unknown [IPv6:2001:980:3ff0::69]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 117EFE09C0 for ; Thu, 10 Jan 2019 15:30:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=bitzolder.nl; s=cheops; h=Content-Transfer-Encoding:MIME-Version:References :In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=Z2dgBCJR2APjDwcK8PcgiYZ3eu/dgol9J1M/xZ7tSQw=; b=d21Bf5rjqAY9joFGsXL5XbgGg0 mSXHYBYNnQ9NZJhdBbjwFBARar+irO5JPJj1mXhqzMGZ1OPrtmJLdnHxwyIEMqwHmm9WMKwojxxwh O03huhxQxAcJKgG8G3+W9Zz2NLK5rUZa8ArJWtLjIfQ3+/Vhs+dBf3y4G93tGRPajAMU=; Received: from hollandscheleeuw.cheops.bitzolder.nl ([2001:980:3ff0:64:5054:ff:fe0b:7015]) by khnum.cheops.bitzolder.nl with esmtp (Exim 4.91) (envelope-from ) id 1ghcHu-0002gM-3t; Thu, 10 Jan 2019 16:30:32 +0100 From: Fabian Groffen To: gentoo-portage-dev@lists.gentoo.org Cc: Fabian Groffen Subject: [gentoo-portage-dev] [PATCH v5] collision_protect: use dynamic report interval Date: Thu, 10 Jan 2019 16:30:14 +0100 Message-Id: <20190110153013.6186-1-grobian@gentoo.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190109083323.3590-1-grobian@gentoo.org> References: <20190109083323.3590-1-grobian@gentoo.org> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-portage-dev@lists.gentoo.org Reply-to: gentoo-portage-dev@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: SpamAssassin/ClamAV at khnum.cheops.bitzolder.nl X-Archives-Salt: 12c7913e-aea7-44b0-8b37-8e7b5230d8fe X-Archives-Hash: 8903a1d9ff3fe52278687e7952ab9c24 The reporting of files remaining can look somewhat odd since the report interval is hardcoded to be per 1000 objects. Adjust this interval to be time based. This means that modern (fast) machines likely will never see the countdown messages at all. On slow setups the message will be informative that there is progress, albeit rather slowly. While at it, report percentage done. Output before this patch: * checking 6158 files for package collisions 5158 files remaining ... 4158 files remaining ... 3158 files remaining ... 2158 files remaining ... 1158 files remaining ... 158 files remaining ... Possible output after this patch on a slower machine: * checking 6158 files for package collisions 48% done, 3145 files remaining ... 96% done, 192 files remaining ... 100% done Signed-off-by: Fabian Groffen --- lib/portage/dbapi/vartree.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/portage/dbapi/vartree.py b/lib/portage/dbapi/vartree.py index 4b91caea8..909c0e473 100644 --- a/lib/portage/dbapi/vartree.py +++ b/lib/portage/dbapi/vartree.py @@ -35,6 +35,7 @@ portage.proxy.lazyimport.lazyimport(globals(), 'portage.util.install_mask:install_mask_dir,InstallMask', 'portage.util.listdir:dircache,listdir', 'portage.util.movefile:movefile', + 'portage.util.monotonic:monotonic', 'portage.util.path:first_existing,iter_parents', 'portage.util.writeable_check:get_ro_checker', 'portage.util._xattr:xattr', @@ -3475,13 +3476,21 @@ class dblink(object): symlink_collisions = [] destroot = self.settings['ROOT'] totfiles = len(file_list) + len(symlink_list) + previous = monotonic() + progress_shown = False + report_interval = 1.7 # seconds + falign = len("%d" % totfiles) showMessage(_(" %s checking %d files for package collisions\n") % \ (colorize("GOOD", "*"), totfiles)) for i, (f, f_type) in enumerate(chain( ((f, "reg") for f in file_list), ((f, "sym") for f in symlink_list))): - if i % 1000 == 0 and i != 0: - showMessage(_("%d files remaining ...\n") % (totfiles - i)) + current = monotonic() + if current - previous > report_interval: + showMessage(_("%3d%% done, %*d files remaining ...\n") % + (i * 100 / totfiles, falign, totfiles - i)) + previous = current + progress_shown = True dest_path = normalize_path( os.path.join(destroot, f.lstrip(os.path.sep))) @@ -3570,6 +3579,8 @@ class dblink(object): break if stopmerge: collisions.append(f) + if progress_shown: + showMessage(_("100% done\n")) return collisions, dirs_ro, symlink_collisions, plib_collisions def _lstat_inode_map(self, path_iter): -- 2.20.1