From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/9323 Path: main.gmane.org!not-for-mail From: David Moore Newsgroups: gmane.emacs.gnus.general Subject: Re: Quicker exit and re-enter of large groups Date: 08 Jan 1997 16:10:21 -0800 Sender: dmoore@sdnp5.ucsd.edu Message-ID: References: NNTP-Posting-Host: coloc-standby.netfonds.no X-Trace: main.gmane.org 1035149366 17812 80.91.224.250 (20 Oct 2002 21:29:26 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Sun, 20 Oct 2002 21:29:26 +0000 (UTC) Return-Path: Original-Received: from ifi.uio.no (0@ifi.uio.no [129.240.64.2]) by deanna.miranova.com (8.8.4/8.8.4) with SMTP id QAA04636 for ; Wed, 8 Jan 1997 16:35:09 -0800 Original-Received: from UCSD.EDU (mailbox2.ucsd.edu [132.239.1.54]) by ifi.uio.no with ESMTP (8.6.11/ifi2.4) id for ; Thu, 9 Jan 1997 01:12:35 +0100 Original-Received: from sdnp5.ucsd.edu (sdnp5.ucsd.edu [132.239.79.10]) by UCSD.EDU (8.8.3/8.6.9) with SMTP id QAA18269 for ; Wed, 8 Jan 1997 16:12:32 -0800 (PST) Original-Received: by sdnp5.ucsd.edu (SMI-8.6/SMI-SVR4) id QAA21646; Wed, 8 Jan 1997 16:10:22 -0800 Original-To: "(ding) Gnus Mailing List" X-Face: "oX;zS#-JU$-,WKSzG.1gGE]x^cIg!hW.dq>.f6pzS^A+(k!T|M:}5{_%>Io<>L&{hO7W4cicOQ|>/lZ1G(m%7iaCf,6Qgk0%%Bz7b2-W3jd0m_UG\Y;?]}4s0O-U)uox>P3JN)9cm]O\@,vy2e{`3pb!"pqmRy3peB90*2L Mail-Copies-To: never In-Reply-To: Ken Raeburn's message of 08 Jan 1997 13:12:16 -0800 Original-Lines: 127 X-Mailer: Red Gnus v0.79/XEmacs 19.15 Xref: main.gmane.org gmane.emacs.gnus.general:9323 X-Report-Spam: http://spam.gmane.org/gmane.emacs.gnus.general:9323 Ken Raeburn writes: > I do likewise. Last time I did some profiling, gnus-dd-mmm took a big > chunk of that time -- nearly a third. It's called for every message. > Can we speed it up somehow? Or, more to the point, cut the cost of a > large number of invocations, perhaps with some sort of caching? You have '%d' in your gnus-summary-line-format which is your gnus-dd-mmm cost. You could always take it out. ;-) More seriously, here's a semi-package I wrote a while back to do generic caching on pure functions (ie ones whose result only depends on their arguments). I had meant to clean it up and rewrite it to be a bit more general for supporting even situations where you don't have pure functions but the other variables don't change very often. Hmm, and this version uses defadvice, which I had planned to change before I tried to convince Lars to slap it into Gnus around various things. In your .gnus stick in something like: (require 'cachize) (cachize 'gnus-dd-mmm 10000) (cachize 'mail-extract-address-components 5000) If you use bbdb to mark known posters, definitely use the second one, it'll speed up summary display by an order of magnitude on large groups. Note the cache is LRU, and each slot in it takes 20 bytes. But if you make the number of slots too small, you can thrash on the cache. Of course, this'll make it have slighly worse performance. :) ;;; David Moore ;;; This uncommented caching code is in the public domain. Enjoy. ;;; ;;; Usage: ;;; ;;; (require 'cachize) ;;; (cachize 'mail-extract-address-components 5000) ;;; ;;; Yep, that's right, no operations to resize the cache or flush them, etc. ;;; You can use ad-unadvise to turn off the caching on a function. ;;; ;;; Note: be sure to only use this on pure functions. (defvar cachize-data (make-hashtable 100 'eq)) (defvar cachize-info nil) ; overbound with let (defmacro cachize-info-get-size () `(aref cachize-info 0)) (defmacro cachize-info-get-cache () `(aref cachize-info 1)) (defmacro cachize-info-get-cnt () `(aref cachize-info 2)) (defmacro cachize-info-inc-cnt () `(aset cachize-info 2 (1+ (aref cachize-info 2)))) (defmacro cachize-info-get-head () `(aref cachize-info 3)) (defmacro cachize-info-set-head (head) `(aset cachize-info 3 ,head)) (defmacro cachize-info-get-tail () `(aref cachize-info 4)) (defun cachize-pop (entry) (let ((next (aref entry 1)) (prev (aref entry 2))) (when prev (aset prev 1 next)) (when next (aset next 2 prev)) (aset entry 1 nil) (aset entry 2 nil))) (defun cachize-insert (entry) (let ((head (cachize-info-get-head))) (aset entry 1 (aref head 1)) (aset entry 2 head) (aset head 1 entry) (aset (aref entry 1) 2 entry))) (defun cachize (funsym size) (unless (gethash funsym cachize-data) (let* ((head (vector nil nil nil nil)) (tail (vector nil nil nil nil)) (info (vector size (make-hashtable size 'equal) 0 head tail))) (aset head 1 tail) (aset tail 2 head) (puthash funsym info cachize-data)) (eval `(defadvice ,funsym (around cachize activate compile) "This function is slow and therefore being cachized!" (let* ((cachize-info (gethash (quote ,funsym) cachize-data)) (cachize-cache (cachize-info-get-cache))) (when (>= (cachize-info-get-cnt) (cachize-info-get-size)) (let ((old (aref (cachize-info-get-tail) 2))) (cachize-pop old) (remhash (aref old 3) cachize-cache))) (let ((cachize-entry (gethash (ad-get-args 0) cachize-cache))) (unless cachize-entry (cachize-info-inc-cnt) (let ((args (copy-tree (ad-get-args 0)))) (setq cachize-entry (vector nil nil nil args)) (puthash args cachize-entry cachize-cache)) ad-do-it (aset cachize-entry 0 ad-return-value)) (cachize-pop cachize-entry) (cachize-insert cachize-entry) (setq ad-return-value (aref cachize-entry 0)))))))) (provide 'cachize) -- David Moore | Computer Systems Lab __o UCSD Dept. Computer Science - 0114 | Work: (619) 534-8604 _ \<,_ La Jolla, CA 92093-0114 | Fax: (619) 534-1445 (_)/ (_) |