From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/85181 Path: news.gmane.org!not-for-mail From: Eric Abrahamsen Newsgroups: gmane.emacs.gnus.general Subject: [PATCH] Two issues with the gnus-registry Date: Fri, 24 Oct 2014 12:04:25 -0700 Message-ID: <87egtx70hy.fsf@ericabrahamsen.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1414177230 8484 80.91.229.3 (24 Oct 2014 19:00:30 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 24 Oct 2014 19:00:30 +0000 (UTC) To: ding@gnus.org Original-X-From: ding-owner+M33425@lists.math.uh.edu Fri Oct 24 21:00:23 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 1Xhk62-00031f-Pf for ding-account@gmane.org; Fri, 24 Oct 2014 21:00:23 +0200 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 1Xhk5d-00039o-HK; Fri, 24 Oct 2014 13:59:57 -0500 Original-Received: from mx1.math.uh.edu ([129.7.128.32]) by util0.math.uh.edu with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1Xhk5b-00039H-8z for ding@lists.math.uh.edu; Fri, 24 Oct 2014 13:59:55 -0500 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx1.math.uh.edu with esmtps (TLSv1:AES128-SHA:128) (Exim 4.76) (envelope-from ) id 1Xhk5Q-00009G-SE for ding@lists.math.uh.edu; Fri, 24 Oct 2014 13:59:55 -0500 Original-Received: from plane.gmane.org ([80.91.229.3]) by quimby.gnus.org with esmtp (Exim 4.80) (envelope-from ) id 1Xhk5F-0006bu-Eh for ding@gnus.org; Fri, 24 Oct 2014 20:59:36 +0200 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1Xhk5F-0002fW-7F for ding@gnus.org; Fri, 24 Oct 2014 20:59:33 +0200 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 ; Fri, 24 Oct 2014 20:59:33 +0200 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 ; Fri, 24 Oct 2014 20:59:33 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 64 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:wc8/F26mkWZFCwymBDjDqeEFqTM= X-Spam-Score: -4.3 (----) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:85181 Archived-At: Hi there, I'm using the gnus-registry in Gnorb to keep track of correspondences between Gnus messages and Org headings, using a key on the registry entries called 'gnorb-ids. This is meant to be a "precious" key, ie entries with this key are not pruned. So far so good: (oref gnus-registry-db :precious) => (gnorb-ids mark) But the entries still do get pruned! I've just had tracked entries start disappearing on me, and realized that they're getting pruned from the registry when I save it. There appear to be two problems here: 1. The pruning doesn't start with the oldest entries first. The docstring of `registry-prune' says it will, but looking over the code in both registry.el and gnus-registry.el, I don't see how that would happen. The entries aren't sorted as they're entered, nor does `gnus-registry-save' pass a sortfun in to `registry-save'. In fact, the entries I'm losing are the most recently-created ones. 2. The bigger problem is that "precious" entries still seem to get pruned. This is really difficult to edebug, because of the enormous loops involved, and because any time the cursor passes the "db" variable and tries to pretty-print it, Emacs runs out of memory (my registry has about 18,000 entries in it). But something is still wrong here! I added a sortfun to the `gnus-registry-save' call, but obviously it slows the save process *way* the heck down. I'm not sure what else to do, though, since (as far as I know) hash tables aren't guaranteed to keep their sort order. Is that correct? And I really don't know why the precious entries are getting pruned. In a day or so, when I have more time, I'll test with a dummy registry, with max-entries set to 10 and 'creation-time added to the precious entries -- should make debugging easier. Thanks, eric Here's the version of gnus-registry-save with the sort routine added: (defun gnus-registry-save (&optional file db) "Save the registry cache file." (interactive) (let ((file (or file gnus-registry-cache-file)) (db (or db gnus-registry-db))) (gnus-message 5 "Saving Gnus registry (%d entries) to %s..." (registry-size db) file) (registry-prune db (lambda (l r) (let ((l-time (car (gnus-registry-get-id-key l 'creation-time))) (r-time (car (gnus-registry-get-id-key r 'creation-time)))) ;; Put oldest entries at the front of the ;; list. (time-less-p r-time l-time)))) ;; TODO: call (gnus-string-remove-all-properties v) on all elements? (eieio-persistent-save db file) (gnus-message 5 "Saving Gnus registry (size %d) to %s...done" (registry-size db) file)))