Skip to content

Notification replay

An operator wants to resend four webhook events and has room for eight deliveries. Three events are order updates and one is a refund. Each event goes to every subscription on its topic. With three order subscriptions and one refund subscription, the replay creates **10 deliveries** (`3 × 3 + 1 × 1`). Move two subscriptions from orders to refunds and the same batch creates **6 deliveries** (`3 × 1 + 1 × 3`). This problem checks the delivery cap before creating any of those pairs.

An operator wants to resend four webhook events and has room for eight deliveries. Three events are order updates and one is a refund. Each event goes to every subscription on its topic. With three order subscriptions and one refund subscription, the replay creates 10 deliveries (3 × 3 + 1 × 1). Move two subscriptions from orders to refunds and the same batch creates 6 deliveries (3 × 1 + 1 × 3). This problem checks the delivery cap before creating any of those pairs.

With 100 ranges, summaries approve 16 of 32 replays and cost a mean 43,200 bytes, against 80,000 to fetch both count arrays

  • knotkit/frequency-table: Maintains exact counts, prefix sums, range sums, and rank selection over a fixed integer domain
  • knotkit/inverted-index: Indexes records by exact keys and scans sorted record IDs for one key or the union of several, using packed posting lists
{"v":1,"box":[71.6962,94.1597,1043,444.3555],"x":{"s":"linear","lim":[-0.4279,2.4279],"inv":false,"g":0,"t":"Counting method","tk":[[0,"Global bound"],[1,"Topic bounds"],[2,"Exact count"]]},"y":{"s":"linear","lim":[0,10.45],"inv":false,"g":0,"tk":[[0,"0"],[8,"cap 8"],[10,"10"]]},"ti":"Orders-heavy: bound 10 > cap 8; exact count 10 rejects","a":[{"k":"bar","c":"#5b6b7c","s":"x","d":[0,10,1,10],"p":[217.23,109.24,557.35,109.24]},{"k":"bar","c":"#1d5fa6","s":"x","d":[2,10],"p":[897.46,109.24]},{"k":"segments","c":"#8c8c84"},{"k":"line","c":"#8c8c84"},{"k":"annotation","c":"#5c5c57"}],"lg":[]} Global bound Topic bounds Exact count Counting method 0 cap 8 10 Deliveries Orders-heavy: bound 10 > cap 8; exact count 10 rejects {"v":1,"box":[71.6962,605.1597,1043,955.3555],"x":{"s":"linear","lim":[-0.4279,2.4279],"inv":false,"g":1,"t":"Counting method","tk":[[0,"Global bound"],[1,"Topic bounds"],[2,"Exact count"]]},"y":{"s":"linear","lim":[0,10.45],"inv":false,"g":1,"tk":[[0,"0"],[6,"6"],[8,"cap 8"],[10,"10"]]},"ti":"Refunds-heavy: bound 6 ≤ cap 8 approves without a count","a":[{"k":"bar","c":"#5b6b7c","s":"x","d":[0,10],"p":[217.23,620.24]},{"k":"bar","c":"#1d5fa6","s":"x","d":[1,6,2,0],"p":[557.35,754.29,897.46,955.36]},{"k":"segments","c":"#8c8c84"},{"k":"segments","c":"#fffff8"},{"k":"line","c":"#8c8c84"},{"k":"annotation","c":"#2b2b28"},{"k":"annotation","c":"#5c5c57"}],"lg":[]} Global bound Topic bounds Exact count Counting method 0 6 cap 8 10 not needed Deliveries Refunds-heavy: bound 6 ≤ cap 8 approves without a count
{"v":1,"box":[71.6962,122.3921,595,444.3555],"x":{"s":"linear","lim":[-0.4279,2.4279],"inv":false,"g":0,"t":"Counting method","tk":[[0,"Global bound"],[1,"Topic bounds"],[2,"Exact count"]]},"y":{"s":"linear","lim":[0,10.45],"inv":false,"g":0,"tk":[[0,"0"],[8,"cap 8"],[10,"10"]]},"ti":"Orders-heavy: bound 10 > cap 8; exact\ncount 10 rejects","a":[{"k":"bar","c":"#5b6b7c","s":"x","d":[0,10,1,10],"p":[150.11,136.26,333.35,136.26]},{"k":"bar","c":"#1d5fa6","s":"x","d":[2,10],"p":[516.59,136.26]},{"k":"segments","c":"#8c8c84"},{"k":"line","c":"#8c8c84"},{"k":"annotation","c":"#5c5c57"}],"lg":[]} Global bound Topic bounds Exact count Counting method 0 cap 8 10 Deliveries Orders-heavy: bound 10 > cap 8; exact count 10 rejects {"v":1,"box":[71.6962,633.3921,595,955.3555],"x":{"s":"linear","lim":[-0.4279,2.4279],"inv":false,"g":1,"t":"Counting method","tk":[[0,"Global bound"],[1,"Topic bounds"],[2,"Exact count"]]},"y":{"s":"linear","lim":[0,10.45],"inv":false,"g":1,"tk":[[0,"0"],[6,"6"],[8,"cap 8"],[10,"10"]]},"ti":"Refunds-heavy: bound 6 ≤ cap 8 approves\nwithout a count","a":[{"k":"bar","c":"#5b6b7c","s":"x","d":[0,10],"p":[150.11,647.26]},{"k":"bar","c":"#1d5fa6","s":"x","d":[1,6,2,0],"p":[333.35,770.5,516.59,955.36]},{"k":"segments","c":"#8c8c84"},{"k":"segments","c":"#fffff8"},{"k":"line","c":"#8c8c84"},{"k":"annotation","c":"#2b2b28"},{"k":"annotation","c":"#5c5c57"}],"lg":[]} Global bound Topic bounds Exact count Counting method 0 6 cap 8 10 not needed Deliveries Refunds-heavy: bound 6 ≤ cap 8 approves without a count
  • Four events and four subscriptions. Delivery cap is 8.
  • Most subscriptions on orders gives 10 deliveries, rejected after counting.
  • Most subscriptions on refunds gives 6 deliveries, approved from topic summaries.

Hover or focus a chart for exact values. Drawn by demo.ts at build time, from the fixtures the benchmark uses; it reproduces the README figure.

Terminal window
git clone https://github.com/jkomyno/knotkit.git && cd knotkit && bun install
bun run demo:problem:notification-replay

problems/notification-replay/README.md states the fixture, the seed, and the result table.