sp1ff/elfeed-score

Do not let rules sit in memory for too long

sp1ff opened this issue · 6 comments

sp1ff commented

Presently, rules & their state (last match time, # hits, &c) are flushed to disk when:

  1. a scoring operation is performed (elfeed-score-score or elfeed-score-search)
  2. it is explicitly requested (elfeed-score-serde-write-score-file)
  3. elfeed-score is unloaded (elfeed-score-unload)

Otherwise, if you simply leave elfeed-score in place, day after day, reading news & relying on the Elfeed new entry hook to score entries, a lot of state accumulates in-memory that won't be written to disk.
Worse, if you update your score file by hand (to add a new rule, say), and then carry out one of the above three operations, your changes will be overwritten.

elfeed-score needs to:

  1. at minimum, check to see if the score file has been touched since last read and refuse to overwrite without confirmation; in practice, this shouldn't be too bad, since in the overwhelming number of cases, the edit will be to add new rules and so the user should be able to copy off the changes, accept the write & just re-add the new rules
  2. better would be to arrange to have rule state written out to disk more regularly, to preclude the case described in 1. This could be done on a timer. It could be done based on some sort of counter (e.g. write state every n times the new entry hook is invoked). It could also be done every time an elfeed-search-fetch operation completes, but since that's asynchronous, it's touchy. We could setup a feed update hook & write every time the work queue goes to zero, but there's no clear "I'm done" signal from that operation.

It is not clear to me what the right answer is, here. @firmart -- you first raised this issue... thoughts?

sp1ff commented

Wrote down some thoughts on this. Starting work this week, along the lines of your proposal 3 @firmart.

sp1ff commented

Fixed. Give it a whirl @firmart & let me know how it works!

sp1ff commented

Awesome-- thx @firmart