Cut sync delay: settable 30–60s interval, and sync when agents check for changes #115

Closed
opened 2026-11-27 22:15:45 +00:00 by jfro · 0 comments
Owner

Marked-up review pages take a long time to reach agents (Fortysix listeners included). Most of that wait is rm-analyzer's scheduled sync: sync_interval: :timer.minutes(15) in config/config.exs, with no override in runtime.exs.

A sync that finds nothing new is already cheap. It makes one GET /sync/v4/root and stops if root.hash == account.root_hash (lib/rm_analyzer/remarkable/sync.ex:54). So checking far more often costs almost nothing.

1. Shorter, settable interval

  • Default sync_interval to 60s (or 30s).
  • Read an override from the environment in runtime.exs, e.g. RM_SYNC_INTERVAL in seconds, where 0 or empty turns the scheduled sync off.
  • Make sure an unchanged root stays cheap: no OCR, backup or tagging scans unless something changed.

2. Sync when an agent asks for changes

  • When list_changes is called, or rm-analyzer://changes is read or subscribed to, call SyncServer.sync_soon/1 for the key's user if their last sync is more than about 30s old.
  • Debounce so several agents checking at once start only one sync.
  • The notifications/resources/updated push to subscribers already fires once a sync records changes, so no change is needed there.

Not included: reMarkable's cloud notifications websocket (instant push). It's unofficial and more work, and can be revisited if 1 and 2 aren't enough.

Done when: an edit the tablet has uploaded shows up in list_changes (and as a resource update) within about a minute with nothing triggering it, and within a few seconds when an agent is checking. Tests cover the env override and the stale-sync trigger with its debounce.

Marked-up review pages take a long time to reach agents (Fortysix listeners included). Most of that wait is rm-analyzer's scheduled sync: `sync_interval: :timer.minutes(15)` in `config/config.exs`, with no override in `runtime.exs`. A sync that finds nothing new is already cheap. It makes one `GET /sync/v4/root` and stops if `root.hash == account.root_hash` (`lib/rm_analyzer/remarkable/sync.ex:54`). So checking far more often costs almost nothing. ## 1. Shorter, settable interval - Default `sync_interval` to 60s (or 30s). - Read an override from the environment in `runtime.exs`, e.g. `RM_SYNC_INTERVAL` in seconds, where 0 or empty turns the scheduled sync off. - Make sure an unchanged root stays cheap: no OCR, backup or tagging scans unless something changed. ## 2. Sync when an agent asks for changes - When `list_changes` is called, or `rm-analyzer://changes` is read or subscribed to, call `SyncServer.sync_soon/1` for the key's user if their last sync is more than about 30s old. - Debounce so several agents checking at once start only one sync. - The `notifications/resources/updated` push to subscribers already fires once a sync records changes, so no change is needed there. Not included: reMarkable's cloud notifications websocket (instant push). It's unofficial and more work, and can be revisited if 1 and 2 aren't enough. Done when: an edit the tablet has uploaded shows up in `list_changes` (and as a resource update) within about a minute with nothing triggering it, and within a few seconds when an agent is checking. Tests cover the env override and the stale-sync trigger with its debounce.
jfro closed this issue 2026-11-28 03:18:50 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
jfro/rm-analyzer#115
No description provided.