From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/69268 Path: news.gmane.org!not-for-mail From: Katsumi Yamaoka Newsgroups: gmane.emacs.gnus.general Subject: Re: faster gnus-thread-latest-date Date: Tue, 08 Dec 2009 16:07:40 +0900 Organization: Emacsen advocacy group Message-ID: References: <87my1uiien.fsf@uwo.ca> <87hbs2yw7f.fsf@uwo.ca> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1260256949 23584 80.91.229.12 (8 Dec 2009 07:22:29 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 8 Dec 2009 07:22:29 +0000 (UTC) Cc: ding@gnus.org To: Dan Christensen Original-X-From: ding-owner+M17673@lists.math.uh.edu Tue Dec 08 08:22:22 2009 Return-path: Envelope-to: ding-account@gmane.org Original-Received: from util0.math.uh.edu ([129.7.128.18]) by lo.gmane.org with esmtp (Exim 4.50) id 1NHuOr-0005Ke-S7 for ding-account@gmane.org; Tue, 08 Dec 2009 08:22:22 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by util0.math.uh.edu with smtp (Exim 4.63) (envelope-from ) id 1NHuNy-0006th-Lj; Tue, 08 Dec 2009 01:21:26 -0600 Original-Received: from mx2.math.uh.edu ([129.7.128.33]) by util0.math.uh.edu with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1NHuBK-0006pg-OQ for ding@lists.math.uh.edu; Tue, 08 Dec 2009 01:08:22 -0600 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx2.math.uh.edu with esmtp (Exim 4.69) (envelope-from ) id 1NHuBI-0006Dp-Pd for ding@lists.math.uh.edu; Tue, 08 Dec 2009 01:08:22 -0600 Original-Received: from orlando.hostforweb.net ([216.246.45.90]) by quimby.gnus.org with esmtp (Exim 3.36 #1 (Debian)) id 1NHuBH-0001km-00 for ; Tue, 08 Dec 2009 08:08:19 +0100 Original-Received: from localhost ([127.0.0.1]:33829) by orlando.hostforweb.net with esmtpa (Exim 4.69) (envelope-from ) id 1NHu7Q-0001gD-6w; Tue, 08 Dec 2009 01:04:20 -0600 X-Hashcash: 1:20:091208:jdc@uwo.ca::bUKeSt9hPfJU3Z1M:00000001zDi X-Hashcash: 1:20:091208:ding@gnus.org::FhB+Jco28kXyCq0N:00002IN1 X-Face: #kKnN,xUnmKia.'[pp`;Omh}odZK)?7wQSl"4o04=EixTF+V[""w~iNbM9ZL+.b*_CxUmFk B#Fu[*?MZZH@IkN:!"\w%I_zt>[$nm7nQosZ<3eu;B:$Q_:p!',P.c0-_Cy[dz4oIpw0ESA^D*1Lw= L&i*6&( User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.1.50 (gnu/linux) Cancel-Lock: sha1:gYWgDb1KxyK0ADNUITNTxvfw+Q8= X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - orlando.hostforweb.net X-AntiAbuse: Original Domain - gnus.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - jpl.org X-Source: X-Source-Args: X-Source-Dir: X-Spam-Score: -2.6 (--) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:69268 Archived-At: >>>>> In <87my1uiien.fsf@uwo.ca> Dan Christensen wrote: > The function gnus-thread-latest-date is used by > gnus-thread-sort-by-most-recent-date, and is very slow. The current > code is: [...] > Since all that is desired is the latest date, I don't see why dates that > don't parse are replaced by the date of the article with the previous > number. Why not just replace them with zero? And if you do that, then > there is no need for a preliminary sort by number. So I think the > following version should produce identical output: [...] I also concluded neither the use of the previous date nor sorting by the article number is useful. >>>>> In <87hbs2yw7f.fsf@uwo.ca> Dan Christensen wrote: [...] > However, I think there's an orthogonal change which could greatly > improve the sorting speed. [...] > Another option would be to cache the slow computations with the thread > while doing the sort. I wasn't sure of the best way to do this, so I > made up another extra-header to temporarily store the date converted > to a float. And the speed-up is amazing. The sorting time goes from > about 10 seconds to under 1 second! Here's the code I used: > The lambda in the original code has been factored out into a separate > function which checks whether the data has been cached: > (defun gnus-article-float-date (header) > (let ((extra-header (mail-header-extra header))) > (or (cdr (assq 'Float-Date extra-header)) > (let ((float-date (condition-case () > (gnus-float-time (mail-header-parse-date > (mail-header-date header))) > (error 0)))) > (mail-header-set-extra header > (cons `(Float-Date . ,float-date) extra-header)) > float-date)))) > (defun gnus-thread-latest-date (thread) > "Return the highest article date in THREAD." > (apply 'max > (mapcar 'gnus-article-float-date > (message-flatten-list thread)))) > Can anyone see any problems with caching the data like this? [...] Great. I tried this one and found no problem so far, except for the subroutine name. The gnus-article- prefix reminds me of an article function in gnus-art.el. Could it be changed into something another? And please provide the ChangeLog entry. The Emacs 23.2 pretest will begin soon and we will be in feature freeze.