Repository navigation
fix(onlion): read the newest pending entries, not the oldest - #120
Merged
Merged
Conversation
The search window took the head of the arrival order, which is the fold's order and the wrong one for reading: with twenty pending entries, markers 0-7 were found and 8-19 were missing, and nothing recovers them because a search never folds and the fold is triggered by the counter. The newest entries - the ones a streaming update just added - were exactly the invisible ones. `listPending` takes an optional `newest`, which slices the tail of the key list before any body is read (names sort in arrival order, so no skipped entry costs a GET) and returns the tail of the matches. The search path passes it; the fold does not, so entries are still applied in the order they arrived. One test pins both directions. Cost: the newest branch reads every body in its tail window before slicing, because the generation filter has to see them - up to about fifteen small objects per search at the observed pending ceiling. Verified: npm run verify passes (34 PASS) and the live marker experiment after deployment.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this fixes
The search window read the oldest pending entries. Measured on the deployed service with
twenty sequential Adds to one user (below the fold trigger, so nothing folded):
The window held the first eight entries and hid the rest, and nothing recovers them: a search
never folds (by design), and the fold is triggered by the pending counter, which only moves on
Add. In steady state pending sits between 16 and 23, so the affected entries are the newest
8–15 - exactly the ones a streaming update just added.
The change
listPendingtakes an optionalnewest: it slices the tail of the key list before readingany body (names sort in arrival order, so skipped entries cost no GET) and returns the tail
of the matches.
pendingForSearchpasses it. The fold does not, so entries are still applied in arrivalorder.
Cost: the newest branch reads every body in its tail window before slicing, since the
generation filter must see them - up to about fifteen small objects per search at the observed
pending ceiling. That is latency traded for correctness, and it is the only thing to watch.
Verification
npm run verifyin onlion: 34 PASS (the new assertion included), eslint clean.