Commit 4d184bd
committed
io: Read only as many objects as a store needs
Seeding a store meant reading its entire namespace, which for a
bounded cache means fetching a node's whole payment history at
startup only to drop all but the newest entries. The previous commit
sidestepped that by not seeding the payment store at all, leaving it
cold and no longer catching unreadable payment data at build time.
Give the reader a bound instead, and seed the payment store with the
newest 50 payments. That matches the storage backends' page size, so
warming the cache costs a single page listing and one batch of reads,
and the first page of `Node::list_payments` is answered without going
to the store.
Take the keys from the paginated listing rather than `KVStore::list`,
which is documented to return them in arbitrary order and would
therefore make "the newest 50" meaningless. Objects now come back in
the store's own creation order, newest first, where before they came
back in whatever order the reads happened to finish.
Note the cache treats the objects it is seeded with as increasingly
recently used, so a newest-first read has to be reversed before
seeding, or the newest entries would be the first ones evicted.
Co-Authored-By: HAL 90001 parent 6bdd6e0 commit 4d184bd
4 files changed
Lines changed: 305 additions & 42 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| 54 | + | |
54 | 55 | | |
55 | 56 | | |
56 | 57 | | |
| |||
61 | 62 | | |
62 | 63 | | |
63 | 64 | | |
64 | | - | |
65 | | - | |
| 65 | + | |
| 66 | + | |
66 | 67 | | |
67 | 68 | | |
68 | 69 | | |
| |||
1456 | 1457 | | |
1457 | 1458 | | |
1458 | 1459 | | |
1459 | | - | |
1460 | | - | |
| 1460 | + | |
| 1461 | + | |
1461 | 1462 | | |
| 1463 | + | |
| 1464 | + | |
| 1465 | + | |
| 1466 | + | |
| 1467 | + | |
| 1468 | + | |
| 1469 | + | |
1462 | 1470 | | |
1463 | 1471 | | |
1464 | 1472 | | |
| |||
1483 | 1491 | | |
1484 | 1492 | | |
1485 | 1493 | | |
1486 | | - | |
1487 | | - | |
1488 | | - | |
1489 | | - | |
1490 | | - | |
1491 | | - | |
1492 | | - | |
1493 | | - | |
1494 | | - | |
1495 | | - | |
1496 | | - | |
| 1494 | + | |
| 1495 | + | |
| 1496 | + | |
| 1497 | + | |
| 1498 | + | |
| 1499 | + | |
| 1500 | + | |
| 1501 | + | |
| 1502 | + | |
| 1503 | + | |
| 1504 | + | |
| 1505 | + | |
| 1506 | + | |
| 1507 | + | |
| 1508 | + | |
| 1509 | + | |
| 1510 | + | |
1497 | 1511 | | |
1498 | 1512 | | |
1499 | 1513 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
60 | 67 | | |
61 | 68 | | |
62 | 69 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
298 | 298 | | |
299 | 299 | | |
300 | 300 | | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
301 | 305 | | |
302 | 306 | | |
303 | 307 | | |
| |||
1648 | 1652 | | |
1649 | 1653 | | |
1650 | 1654 | | |
| 1655 | + | |
| 1656 | + | |
| 1657 | + | |
| 1658 | + | |
| 1659 | + | |
| 1660 | + | |
| 1661 | + | |
| 1662 | + | |
| 1663 | + | |
| 1664 | + | |
| 1665 | + | |
| 1666 | + | |
| 1667 | + | |
| 1668 | + | |
| 1669 | + | |
| 1670 | + | |
| 1671 | + | |
| 1672 | + | |
| 1673 | + | |
| 1674 | + | |
| 1675 | + | |
| 1676 | + | |
| 1677 | + | |
| 1678 | + | |
1651 | 1679 | | |
1652 | 1680 | | |
1653 | 1681 | | |
| |||
0 commit comments