From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: [WIP][PATCH] download: Don't report the progress too fast Date: Sun, 10 Sep 2017 23:25:08 +0200 Message-ID: <877ex6456z.fsf@gnu.org> References: <87d17ilhzq.fsf@member.fsf.org> <87shg978ao.fsf@gnu.org> <87mv652phq.fsf@member.fsf.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:55234) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dr9j6-0003fg-15 for guix-devel@gnu.org; Sun, 10 Sep 2017 17:25:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dr9j4-0007aw-Qa for guix-devel@gnu.org; Sun, 10 Sep 2017 17:25:12 -0400 In-Reply-To: <87mv652phq.fsf@member.fsf.org> (=?utf-8?B?IuWui+aWh+atpiIn?= =?utf-8?B?cw==?= message of "Fri, 08 Sep 2017 23:12:49 +0800") List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: =?utf-8?B?5a6L5paH5q2m?= Cc: guix-devel@gnu.org Hi! iyzsong@member.fsf.org (=E5=AE=8B=E6=96=87=E6=AD=A6) skribis: > Hi, sorry for my late response. No problem, it was worth waiting. ;-) > ludo@gnu.org (Ludovic Court=C3=A8s) writes: [...] >> (Also, longer-term, we=E2=80=99d want to do that other way around, which= is to >> update the report every N milliseconds, as opposed to just printing >> something when a chunk has been transferred.) >> > > Yes, so the elapsed time won't be freezed, and here is my try using > thread: [...] > From 4036ce5de7bf3b98327010bbfbf75029f3d0b572 Mon Sep 17 00:00:00 2001 > From: =3D?UTF-8?q?=3DE5=3DAE=3D8B=3DE6=3D96=3D87=3DE6=3DAD=3DA6?=3D > Date: Fri, 8 Sep 2017 22:49:03 +0800 > Subject: [PATCH] download: Report the progress asynchronously in another > thread. > > * guix/utils.scm (): New record type. > (call-with-progress-reporter): New procedure. > * guix/build/download.scm (dump-port*, progress-reporter/file): New > procedures. > (ftp-fetch, http-fetch): Use them. > (progress-proc): Remove procedure. > * guix/scripts/substitute.scm (progress-report-port): Rewrite in terms of > . > (process-substitution): Adjust accordingly. Impressive! I have a couple of concerns though: 1. Using a thread =E2=80=9Cjust=E2=80=9D for progress reporting seems qui= te heavyweight, though maybe that=E2=80=99s OK. 2. As per POSIX, we cannot mix =E2=80=98fork=E2=80=99 and threads, so pro= grams that use =E2=80=98primitive-fork=E2=80=99 should not also use threads. One= such program is (guix scripts substitute), via =E2=80=98decompressed-port=E2=80=99.= Guile rightfully emits a warning when a multithreaded program calls =E2=80=98primitive-fork=E2=80=99: https://git.savannah.gnu.org/cgit/guile.git/tree/libguile/posix.c#n1= 224 3. =E2=80=9CAtomic boxes=E2=80=9D are a Guile 2.2 feature, but we still = support 2.0. To address these, I would use =E2=80=98abort-to-prompt=E2=80=99 & co., poss= ibly with =E2=80=9Csuspendable ports=E2=80=9D, but this is a 2.2 feature. (It may be= that we should use Fibers directly.) Tricky! Not sure what to do here. Thoughts? Ludo=E2=80=99.