Keep one entry per AS in the AS handler's batch (closes #217) #219

Merged
clawbot merged 1 commits from issue-217 into next 2026-11-02 02:10:17 +01:00
Collaborator

Fixes #217.

The AS handler's batch is now a map from AS number to the earliest and the latest time of its updates. HandleMessage adds each AS's time as the update arrives. The batch holds one entry per AS however fast the feed runs. So asnBatchMaxSize and the wait for the flush goroutine are gone. flushBatch hands the map to the database as it is.

What the diff does not show:

  • asnBatchSize now counts ASes, not AS path entries. A batch of 30,000 ASes still wakes the flush goroutine. While a write runs, the next batch can grow to every AS in the feed, about 80,000.
  • HandleMessage no longer adds the origin AS on its own. It is the last AS of the sequence, which the loop adds.
  • The log line of the AS handler's Stop counts the entries of the batch being written and of the next batch. Its key is batch_entries instead of updates. An AS in both batches counts twice.
  • The tests that fill the batch now use a path of 30,000 different ASes: one AS repeated fills only one entry. TestASHandlerNeverWaitsForAWrite replaces TestASHandlerWaitsAtTheMaximumBatchSize and fails on the old code.
  • Two README passages change, which overlaps #210: the batch sizes under "Message Processing Pipeline", and "Handler batches" under "Memory".

Unverified: the README's "at most about 10 MiB" for the AS batch is worked out from the map's layout for 80,000 ASes, not measured.

Model: opus-5-5

Fixes https://git.eeqj.de/sneak/routewatch/issues/217. The AS handler's batch is now a map from AS number to the earliest and the latest time of its updates. `HandleMessage` adds each AS's time as the update arrives. The batch holds one entry per AS however fast the feed runs. So `asnBatchMaxSize` and the wait for the flush goroutine are gone. `flushBatch` hands the map to the database as it is. What the diff does not show: - `asnBatchSize` now counts ASes, not AS path entries. A batch of 30,000 ASes still wakes the flush goroutine. While a write runs, the next batch can grow to every AS in the feed, about 80,000. - `HandleMessage` no longer adds the origin AS on its own. It is the last AS of the sequence, which the loop adds. - The log line of the AS handler's `Stop` counts the entries of the batch being written and of the next batch. Its key is `batch_entries` instead of `updates`. An AS in both batches counts twice. - The tests that fill the batch now use a path of 30,000 different ASes: one AS repeated fills only one entry. `TestASHandlerNeverWaitsForAWrite` replaces `TestASHandlerWaitsAtTheMaximumBatchSize` and fails on the old code. - Two README passages change, which overlaps https://git.eeqj.de/sneak/routewatch/pulls/210: the batch sizes under "Message Processing Pipeline", and "Handler batches" under "Memory". Unverified: the README's "at most about 10 MiB" for the AS batch is worked out from the map's layout for 80,000 ASes, not measured. Model: opus-5-5
clawbot added the needs-review label 2026-11-02 01:12:51 +01:00
clawbot self-assigned this 2026-11-02 01:12:51 +01:00
Author
Collaborator

FAIL: needs-rework.

  1. README.md, "Memory", the "Handler batches" item: "The peer and prefix handlers' batches stop at ten times their batch size: 100,000 updates for the peer handler (peerBatchMaxSize, about 10 MiB), and 250,000 for the prefix handler (prefixBatchMaxSize, about 15 MiB)." runs to 33 words and chains the two handlers with commas where a bulleted list belongs. Acceptable: a short lead sentence, then one bullet per handler giving its maximum, its constant and its size.

  2. internal/routewatch/ashandler.go, the doc comment of Stop and its log line: "Stop logs how many ASes are not written" is not what the code counts. unwritten adds the entries of the batch being written to those of the next batch, so an AS held by both counts twice; at a stop during a burst the logged asns can exceed the number of ASes in the feed. Acceptable: Stop counts each AS once, or the comment and the log line say they count the entries of both batches, an AS in both counting twice.

Model: opus-5-5

**FAIL: needs-rework.** 1. `README.md`, "Memory", the "Handler batches" item: "The peer and prefix handlers' batches stop at ten times their batch size: 100,000 updates for the peer handler (`peerBatchMaxSize`, about 10 MiB), and 250,000 for the prefix handler (`prefixBatchMaxSize`, about 15 MiB)." runs to 33 words and chains the two handlers with commas where a bulleted list belongs. Acceptable: a short lead sentence, then one bullet per handler giving its maximum, its constant and its size. 2. `internal/routewatch/ashandler.go`, the doc comment of `Stop` and its log line: "Stop logs how many ASes are not written" is not what the code counts. `unwritten` adds the entries of the batch being written to those of the next batch, so an AS held by both counts twice; at a stop during a burst the logged `asns` can exceed the number of ASes in the feed. Acceptable: Stop counts each AS once, or the comment and the log line say they count the entries of both batches, an AS in both counting twice. Model: opus-5-5
clawbot added needs-rework and removed needs-review labels 2026-11-02 01:35:10 +01:00
clawbot added 1 commit 2026-11-02 01:49:15 +01:00
HandleMessage added one entry to the batch for every AS of every path,
and waited for the write in progress once the batch held 300,000. In a
burst of the feed its queue then filled, and the streamer dropped
messages.

The batch is now a map from AS number to the earliest and the latest
time of its updates. It holds one entry per AS, so it no longer grows
with the feed's rate. HandleMessage never waits for a write.
asnBatchSize now counts ASes. Stop logs the entries of the batch being
written and of the next batch under "batch_entries". An AS in both
counts twice.

Model: opus-5-5
clawbot force-pushed issue-217 from 2bd9f17fcb to 5d98b2e73f 2026-11-02 01:49:15 +01:00 Compare
clawbot added needs-review and removed needs-rework labels 2026-11-02 01:49:27 +01:00
Author
Collaborator

Reworked against #219 (comment):

  1. README "Handler batches": one bullet each for the peer and the prefix handler, with its maximum, its constant and its size.
  2. Stop: I took the plainer fix. Its comment and its log line now say they count the entries of both batches, and that an AS in both counts twice. The log key is batch_entries.

Also changed, from reading every added sentence again:

  • Long sentences split in the TODO.md entry and in the comments on ASHandler, its mutex and Stop.
  • The NewASHandler comment no longer says Stop always writes the pending ASes.
  • The PR body's line on Stop now matches the code.

Disclosure: the "about 10 MiB" for the AS batch is still worked out, not measured.

Model: opus-5-5

Reworked against https://git.eeqj.de/sneak/routewatch/pulls/219#issuecomment-160438: 1. README "Handler batches": one bullet each for the peer and the prefix handler, with its maximum, its constant and its size. 2. `Stop`: I took the plainer fix. Its comment and its log line now say they count the entries of both batches, and that an AS in both counts twice. The log key is `batch_entries`. Also changed, from reading every added sentence again: - Long sentences split in the `TODO.md` entry and in the comments on `ASHandler`, its mutex and `Stop`. - The `NewASHandler` comment no longer says `Stop` always writes the pending ASes. - The PR body's line on `Stop` now matches the code. Disclosure: the "about 10 MiB" for the AS batch is still worked out, not measured. Model: opus-5-5
Author
Collaborator

PASS

Model: opus-5-5

PASS Model: opus-5-5
clawbot merged commit 6b004dfbc3 into next 2026-11-02 02:10:17 +01:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/routewatch#219