From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Mark Oteiza Newsgroups: gmane.emacs.devel Subject: Re: [RFC] making image-dired thumbnail creation asynchronous Date: Fri, 16 Dec 2016 08:15:31 -0500 Message-ID: <20161216131531.GA1009@holos.localdomain> References: <87fulo8urt.fsf@udel.edu> <83mvfw8etl.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1481894187 30854 195.159.176.226 (16 Dec 2016 13:16:27 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 16 Dec 2016 13:16:27 +0000 (UTC) User-Agent: Mutt/1.7.2+8 (b112fd7061fb) (2016-11-26) Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Dec 16 14:16:23 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cHsN2-0006Pg-DK for ged-emacs-devel@m.gmane.org; Fri, 16 Dec 2016 14:16:20 +0100 Original-Received: from localhost ([::1]:60471 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cHsN3-00036Z-FV for ged-emacs-devel@m.gmane.org; Fri, 16 Dec 2016 08:16:21 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49651) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cHsMM-00032i-Tr for emacs-devel@gnu.org; Fri, 16 Dec 2016 08:15:39 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cHsMI-0006sP-MN for emacs-devel@gnu.org; Fri, 16 Dec 2016 08:15:38 -0500 Original-Received: from mail-qt0-x22a.google.com ([2607:f8b0:400d:c0d::22a]:36240) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cHsMI-0006rh-C2 for emacs-devel@gnu.org; Fri, 16 Dec 2016 08:15:34 -0500 Original-Received: by mail-qt0-x22a.google.com with SMTP id w33so86203185qtc.3 for ; Fri, 16 Dec 2016 05:15:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=udel-edu.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=ju8YA0LMGOnjbRYZd7umyyFhsTWzaIu/Gb0FgErZ20U=; b=qCAq3zNxehrrF2z+OGxTnqNKBrhSHC6dCzD/jX7qOTHmaFFT36PrBhP680SSQqbnBC UhUunug8evwJxuTHsJ3uVFyF+8kOtxexYc7gryWXte7RVmc672hSHJknLNx9RZYkXUna lDm9FbBaXc7U4UvB7XExwfMISx59dMe1GjrYdKBGUxwQTTjQtNgizm5hXHSi1BEauGI8 7pIqdNOY/dryLtCS856aYVw4nSBHH+oKnX7SlUz5MF5LIzfkSoA6yg8ge3ETSKRsQXiK Tbxd7majdgOsxFHmvtQqmpDNpnwFZbntuw6Z0o93EzNmfHyxjovTzD8z0Aj1nYoZh4MJ 9owA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=ju8YA0LMGOnjbRYZd7umyyFhsTWzaIu/Gb0FgErZ20U=; b=N0o0BC505nm6y/Wki+C9+tp8lWIjqbTJpGusATOHXHXCAe2nu9+psWmoow76M9N3t3 Nq0E10e4ln3sFGmfDQr20TzNfrNmhPkTfv9OYHgg5dekxCx5pSkPXInEIwp50UxHNIro R8wNwLe92qynJ2ISVqAEPqD3oSrhZQ4IFpvubuWmVTx260S6Nfax9jeukoGdV0dAXngH Bf4ACurfVRr00CtrLfGi7prf2tftck0xXlDQFOcuQhtw5s+g1XLvNK1ZrUDNuS0PcwHW TXNJcdd5hTXctYCwLYTgsZSAvKGygf15y5kWw1InnyalsAj0yAfL3RivyPbkFQlDOh0h DLZQ== X-Gm-Message-State: AIkVDXJ/VmRKi695aAo4EAyxKURn8woVn2Rs3X4/QCQ223u3aRPxSCCEXfPuAAgbOj43dxHd X-Received: by 10.200.45.129 with SMTP id p1mr2416280qta.96.1481894133454; Fri, 16 Dec 2016 05:15:33 -0800 (PST) Original-Received: from holos.localdomain ([69.250.222.218]) by smtp.gmail.com with ESMTPSA id i41sm3684300qtc.18.2016.12.16.05.15.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Dec 2016 05:15:32 -0800 (PST) Original-Received: by holos.localdomain (Postfix, from userid 1000) id 5BE5366151; Fri, 16 Dec 2016 08:15:31 -0500 (EST) Content-Disposition: inline In-Reply-To: <83mvfw8etl.fsf@gnu.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400d:c0d::22a X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:210507 Archived-At: On 16/12/16 at 10:21am, Eli Zaretskii wrote: > > From: Mark Oteiza > > Date: Thu, 15 Dec 2016 21:36:38 -0500 > > > > The biggest problem right now is the aforementioned OOM killer problem: > > that there is no notion of batching or scheduling and so potentially a > > large number of "convert" processes get spun off. I'm not sure yet how > > I want to go about implementing that. > > Would load-average help you? > > Or we could add a function that returns the amount of free VM on the > system. > > Or you could arbitrarily limit the number of such processes to some > small value. The latter would probably be the easiest. > > Also, is (redisplay) the right thing to call at the end a thumbnail's > > creations so each of thumbnails get shown automatically as they are > > created? > > Please tell the details of how Emacs is notified about thumbnail > creation (or point to the code which does that), because I don't see > why you would need to explicitly trigger redisplay. It should happen > automatically whenever the buffer contents changes in any way that > affects the displayed portion. @@ -868,10 +1004,9 @@ image-dired-display-thumbs (goto-char (point-max))) (dolist (curr-file files) (setq thumb-name (image-dired-thumb-name curr-file)) - (if (and (not (file-exists-p thumb-name)) - (not (= 0 (image-dired-create-thumb curr-file thumb-name)))) - (message "Thumb could not be created for file %s" curr-file) - (image-dired-insert-thumbnail thumb-name curr-file dired-buf)))) + (when (not (file-exists-p thumb-name)) + (image-dired-create-thumb curr-file thumb-name)) + (image-dired-insert-thumbnail thumb-name curr-file dired-buf))) (if do-not-pop (display-buffer buf) (pop-to-buffer buf)) Here is the relevant hunk. image-dired-create-thumb is the starting point for asynchronous thumbnail creation. At this point, image-dired-insert-thumbnail is called immediately after invoking image-dired-create-thumb, so in practice the buffer has already been populated with images for files that potentially do not yet exist; i.e. the buffer contents are already finished changing before thumbnails are created. There is currently nothing notifying Emacs once a thumbnail has been created, but it would go somewhere in image-dired-create-thumb or one of the functions its sentinel calls (the hunk previous to the one I pasted)