From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/85190 Path: news.gmane.org!not-for-mail From: Eric Abrahamsen Newsgroups: gmane.emacs.gnus.general Subject: Re: [PATCH] Two issues with the gnus-registry Date: Tue, 28 Oct 2014 11:04:44 -0700 Message-ID: <87h9yogjer.fsf@ericabrahamsen.net> References: <87egtx70hy.fsf@ericabrahamsen.net> <87wq7lsggo.fsf@lifelogs.com> <87zjchxr1v.fsf@ericabrahamsen.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1414519235 27964 80.91.229.3 (28 Oct 2014 18:00:35 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 28 Oct 2014 18:00:35 +0000 (UTC) To: ding@gnus.org Original-X-From: ding-owner+M33434@lists.math.uh.edu Tue Oct 28 19:00:28 2014 Return-path: Envelope-to: ding-account@gmane.org Original-Received: from util0.math.uh.edu ([129.7.128.18]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XjB46-0004gM-23 for ding-account@gmane.org; Tue, 28 Oct 2014 19:00:20 +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 1XjB41-0000Sf-8X; Tue, 28 Oct 2014 13:00:13 -0500 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 1XjB3z-0000SU-PM for ding@lists.math.uh.edu; Tue, 28 Oct 2014 13:00:11 -0500 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx2.math.uh.edu with esmtps (TLSv1:AES128-SHA:128) (Exim 4.76) (envelope-from ) id 1XjB3m-0007A4-TX for ding@lists.math.uh.edu; Tue, 28 Oct 2014 13:00:11 -0500 Original-Received: from plane.gmane.org ([80.91.229.3]) by quimby.gnus.org with esmtp (Exim 4.80) (envelope-from ) id 1XjB3j-0007ma-Tq for ding@gnus.org; Tue, 28 Oct 2014 18:59:55 +0100 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1XjB3e-0004KK-1D for ding@gnus.org; Tue, 28 Oct 2014 18:59:50 +0100 Original-Received: from c-76-28-195-250.hsd1.wa.comcast.net ([76.28.195.250]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 28 Oct 2014 18:59:50 +0100 Original-Received: from eric by c-76-28-195-250.hsd1.wa.comcast.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 28 Oct 2014 18:59:50 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 138 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: c-76-28-195-250.hsd1.wa.comcast.net User-Agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/25.0.50 (gnu/linux) Cancel-Lock: sha1:2fHiBig0XMJLfC0QB3/5pfuUmBg= X-Spam-Score: -3.5 (---) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:85190 Archived-At: --=-=-= Content-Type: text/plain Eric Abrahamsen writes: > Ted Zlatanov writes: [...] >> The registry has ERT tests, which I thought covered this case. Can you >> look at `tests/gnustest-registry.el'? As a first step, can you try >> making tests to demonstrate the problems? > > Will do. Okay, turns out there were tests, but the bit that tests pruning was commented out :) This is the first in a (gradual) series of patches. It does very little except: 1. Adjust `registry-prune' to do what the docstring says: return the total number of entries pruned 2. Uncomment the pruning test and adjust it so it correctly catches the number of pruned entries. Test should fail. Over the next couple of days I'll add another test to check that entries are sorted correctly before pruning, and then take a stab at fixing the pruning itself. E --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Test-registry-pruning.patch >From 08491aff0b99e7e7ee04a0310174bc13aa0d1bcd Mon Sep 17 00:00:00 2001 From: Eric Abrahamsen Date: Tue, 28 Oct 2014 09:30:01 -0700 Subject: [PATCH] Test registry pruning * lisp/registry.el (registry-prune): Change function to do what the docstring says: return a count of total entries pruned. * lisp/tests/gnustest-registry.el (gnustest-registry-usage-test): Uncomment pruning part of test, and alter to correctly receive number of entries pruned. --- lisp/registry.el | 40 +++++++++++++++++++++------------------- lisp/tests/gnustest-registry.el | 17 ++++++++--------- 2 files changed, 29 insertions(+), 28 deletions(-) diff --git a/lisp/registry.el b/lisp/registry.el index dbc7b51..1d31d2b 100644 --- a/lisp/registry.el +++ b/lisp/registry.el @@ -319,25 +319,27 @@ then removes oldest entries first. Returns the number of deleted entries. If SORTFUN is given, tries to keep entries that sort *higher*. SORTFUN is passed only the two keys so it must look them up directly." - (dolist (collector '(registry-prune-soft-candidates - registry-prune-hard-candidates)) - (let* ((size (registry-size db)) - (collected (funcall collector db)) - (limit (nth 0 collected)) - (candidates (nth 1 collected)) - ;; sort the candidates if SORTFUN was given - (candidates (if sortfun (sort candidates sortfun) candidates)) - (candidates-count (length candidates)) - ;; are we over max-soft? - (prune-needed (> size limit))) - - ;; while we have more candidates than we need to remove... - (while (and (> candidates-count (- size limit)) candidates) - (decf candidates-count) - (setq candidates (cdr candidates))) - - (registry-delete db candidates nil) - (length candidates)))) + (let ((pruned 0)) + (dolist (collector '(registry-prune-soft-candidates + registry-prune-hard-candidates)) + (let* ((size (registry-size db)) + (collected (funcall collector db)) + (limit (nth 0 collected)) + (candidates (nth 1 collected)) + ;; sort the candidates if SORTFUN was given + (candidates (if sortfun (sort candidates sortfun) candidates)) + (candidates-count (length candidates)) + ;; are we over max-soft? + (prune-needed (> size limit))) + + ;; while we have more candidates than we need to remove... + (while (and (> candidates-count (- size limit)) candidates) + (decf candidates-count) + (setq candidates (cdr candidates))) + + (registry-delete db candidates nil) + (setq pruned (+ candidates-count pruned)))) + pruned)) (defmethod registry-prune-soft-candidates ((db registry-db)) "Collects pruning candidates from the registry-db object THIS. diff --git a/lisp/tests/gnustest-registry.el b/lisp/tests/gnustest-registry.el index 174a0cb..7fa0498 100644 --- a/lisp/tests/gnustest-registry.el +++ b/lisp/tests/gnustest-registry.el @@ -101,15 +101,14 @@ (should (= n (length (registry-search db :all t)))) (message "Secondary search after delete") (should (= n (length (registry-lookup-secondary-value db 'sender "me")))) - ;; (message "Pruning") - ;; (let* ((tokeep (registry-search db :member '((extra "more data")))) - ;; (count (- n (length tokeep))) - ;; (pruned (registry-prune db)) - ;; (prune-count (length pruned))) - ;; (message "Expecting to prune %d entries and pruned %d" - ;; count prune-count) - ;; (should (and (= count 5) - ;; (= count prune-count)))) + (message "Pruning") + (let* ((tokeep (registry-search db :member '((extra "more data")))) + (count (- n (length tokeep))) + (prune-count (registry-prune db))) + (message "Expecting to prune %d entries and pruned %d" + count prune-count) + (should (and (= count 5) + (= count prune-count)))) (message "Done with usage testing."))) (ert-deftest gnustest-registry-persistence-test () -- 2.1.2 --=-=-=--