Gnus development mailing list
 help / color / mirror / Atom feed
From: Eric Abrahamsen <eric@ericabrahamsen.net>
To: ding@gnus.org
Subject: [PATCH] Two issues with the gnus-registry
Date: Fri, 24 Oct 2014 12:04:25 -0700	[thread overview]
Message-ID: <87egtx70hy.fsf@ericabrahamsen.net> (raw)

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)))




             reply	other threads:[~2014-10-24 19:04 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-24 19:04 Eric Abrahamsen [this message]
2014-10-24 20:56 ` Eric Abrahamsen
2014-10-25 19:59   ` Eric Abrahamsen
2014-10-27 15:03 ` Ted Zlatanov
2014-10-27 19:15   ` Eric Abrahamsen
2014-10-28 18:04     ` Eric Abrahamsen
2014-11-07 23:56       ` Eric Abrahamsen
2014-11-08  0:01         ` Eric Abrahamsen
2014-11-08  8:39           ` Eric Abrahamsen
2014-11-10 13:54             ` Ted Zlatanov
2014-11-11  2:55               ` Eric Abrahamsen
2014-11-13 12:05               ` Eric Abrahamsen
2014-11-16  1:04                 ` Dan Christensen
2014-11-16  3:24                   ` Eric Abrahamsen
2014-12-18 10:07                 ` Ted Zlatanov
2014-12-18 15:00                   ` Eric Abrahamsen
2014-12-18 15:09                     ` Eric Abrahamsen
2014-12-19  0:44                       ` Katsumi Yamaoka
2014-12-19  2:08                         ` Eric Abrahamsen
2014-12-20  3:09                         ` Ted Zlatanov
2014-12-20 11:22                           ` Katsumi Yamaoka
2014-12-20 13:53                             ` Older Emacsen (was: [PATCH] Two issues with the gnus-registry) Ted Zlatanov
2014-12-19  1:30                       ` [PATCH] Two issues with the gnus-registry Ted Zlatanov
2014-10-28 20:10     ` Ted Zlatanov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87egtx70hy.fsf@ericabrahamsen.net \
    --to=eric@ericabrahamsen.net \
    --cc=ding@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).