Closed Bug 1846781 Opened 2 years ago Closed 2 years ago

Use recalc_frecency for origins frecency instead of updating in triggers

Categories

(Toolkit :: Places, task, P3)

task

Tracking

()

RESOLVED FIXED
119 Branch
Tracking Status
firefox119 --- fixed

People

(Reporter: mak, Assigned: mak)

References

Details

Attachments

(2 files)

While this will be a bit less performant than the old system updating the score by adding/subtracting in a trigger, it prepares us to take future algorithms that are not just a sum/subtraction, and it's less error-prone.

So far we updated origins frecency in SQL triggers. While this guarantees good
performance, it has some downsides:

  • using different algorithms is complicate, the current system only works
    with a straight sum of page frecencies. We are planning to experiment and
    eventually graduate new algorithms in the future.
  • it requires using multiple temp tables and DELETE triggers, that is quite
    error prone for consumers, they may forget to DELETE from the temp tables
    breaking data coherency.
  • there's not much ATOMicity, since the origins update must be triggered apart
    and a crash would lost the requested changed

This patch is changing the behavior to be closer to the recalc_frecency one that
is used for pages. When pages are added or removed, recalc_frecency of its
origin is set to 1. Later frecencies will be recalculated in chunks.
While this is a bit less efficient than the existing system, it solves all the
problems presented above.
A threshold is recalculated at each chunk, and stored in the moz_meta table.
Temporarily the old STATS are also set in the moz_meta table, to allow for
downgrades. Those can be removed a couple versions in the future.

The after delete temp table is maintained because there's no more efficient way
to remove orphan origins promptly. Thus after removals from moz_places consumers
MUST DELETE from the temp table, otherwise orphan origins may remain. We'll
introduce some maintenance task to remove those, anyway, for privacy reasons.

Attachment #9348704 - Attachment description: WIP: Bug 1846781 - Use recalc_frecency for updating origins frecency instead of triggers. → Bug 1846781 - Use recalc_frecency for updating origins frecency instead of triggers. r=daisuke
Pushed by mak77@bonardo.net: https://hg.mozilla.org/integration/autoland/rev/3020232880d7 Use recalc_frecency for updating origins frecency instead of triggers. r=daisuke
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 119 Branch
Flags: needinfo?(mak)

(In reply to Julian Descottes [:jdescottes] from comment #4)

I see a console.log landed here at https://searchfox.org/mozilla-central/rev/b741ddde6c678ca7025858952202d20664491555/toolkit/components/places/PlacesUtils.sys.mjs#2266

Looks like a leftover, should it be removed?

oops, yes thank you.
I'll add a revision to remove it.

Flags: needinfo?(mak)
Pushed by mak77@bonardo.net: https://hg.mozilla.org/integration/autoland/rev/3a58c7fc0959 remove leftover console.log r=places-reviewers,Standard8
Regressions: 1854169
Blocks: 1854187
Regressions: 1855274
Blocks: 1651189
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: